Extracting a value from each loop of SPSS script

22 Views Asked by At

I am trying to run a loop with python in SPSS that creates 450 outputs of this form Example output

I would like to extract the value in the first row and first column of the intraclass correlation coefficient table for each iteration of the loop and print them so that I can paste those into excel or export it to excel.

I created the following code:

begin program python3.
import spss
import spssaux

i = 1
while (i <= spss.GetVariableCount()-1):
    #spss.Submit("RELIABILITY /VARIABLES= V" + str(i) + " V" + str(i+1) + "/SCALE('ALL VARIABLES') ALL /MODEL=ALPHA /ICC=MODEL(MIXED) TYPE(ABSOLUTE) CIN=95 TESTVAL=0.")
    handle,errcode = spssaux.CreateXMLOutput("RELIABILITY /VARIABLES= V" + str(i) + " V" + str(i+1) + "/SCALE('ALL VARIABLES') ALL /MODEL=ALPHA /ICC=MODEL(MIXED) TYPE(ABSOLUTE) CIN=95 TESTVAL=0.",
                                                                      omsid="Reliability",
                                                                      subtype="Scale Statistics")
    result=spssaux.GetValuesFromXMLWorkspace(handle,
                            tableSubtype="Intraclass Correlation Coefficient",
                            rowCategory="Single Measures",
                            colCategory="Intraclass Correlation",
                            cellAttrib="text")
    print(result)
    i += 2
end program.

However, result is always just an empty array. What am I doing wrong?

0

There are 0 best solutions below