* Encoding: UTF-8. FILE HANDLE data /name="/Users/SPSS/DATA". FILE HANDLE temp /name="c:\temp". ***GET FILE='data/languages/English/Employee data.sav'. dataset declare hetcor. oms select tables /if subtypes='HeterogeneousCorrelations' /destination format=sav outfile=hetcor /tag="_x_". SPSSINC HETCOR gender educ salary salbegin minority /OPTIONS ESTIMATOR=TWOSTEP STDERR=TRUE MISSING=PAIRWISE N=TRUE TYPE=TRUE /SAVE. omsend tag="_x_". begin program Python3. import spssaux varlist=" gender educ salary salbegin minority" my_corrline=[] my_ns=[] IN=spssaux.FileHandles().resolve("temp/matrix.txt") OUT=spssaux.FileHandles().resolve("temp/matrix_data.sps") with open(IN) as file: lines = file.readlines() lines = [line.rstrip() for line in lines] for l in lines: corr=l.find("Correlation ") n=l.find("N ") if corr > 0: my_corrline.append(l[corr:].replace("Correlation",'').strip()) if n > 0: my_ns.append(l[n:].replace("N",'').strip()) F=open(OUT, 'w') print("MATRIX DATA VARIABLES=ROWTYPE_ " + varlist + "\n /FORMAT=FULL.\nBEGIN DATA.",file=F) print("N " + str(my_ns[0].replace("'",'')),file=F) for c in my_corrline: print("CORR " + str(c),file=F) print("END DATA.\n",file=F) F.close() end program. insert file="temp/matrix_data.sps". FACTOR MATRIX IN(COR=*) /MISSING=LISTWISE. begin program python3. import spssaux print(spssaux.FileHandles().resolve(filespec="temp/matrix.txt")) print(spssaux.FileHandles().resolve("temp/matrix_data.sps")) end program. DATASET ACTIVATE DataSet2. FACTOR /VARIABLES gender educ salary /MISSING LISTWISE /ANALYSIS gender educ salary /PRINT INITIAL EXTRACTION /CRITERIA MINEIGEN(1) ITERATE(25) /EXTRACTION PC /ROTATION NOROTATE /METHOD=CORRELATION. 'HeterogeneousCorrelations'