xml - How to retrieve some output values from SPSS Custom Tables? -
i have been trying retrieve specific output values spss custom tables , export them excel. problem ctables syntax generates 2 different tables , want retrieve specific output values both these tables , export excel. link screenshot of spss custom tables. have highlighted values in red want retrieve. trying retrieve these values in xml format, getting error message. here code.
*1. retrieve output values , insert them text. begin program. import spssaux gar="ctables /vlabels variables=institution res_pay status display=label /table status [c] > res_pay [c] institution [c][count f40.0, colpct.count pct40.1] /categories variables=institution order=a key=value empty=include total=yes position=after /categories variables=res_pay empty=include /categories variables=status order=a key=value empty=include /sigtest type=chisquare alpha=0.05 includemrsets=yes categories=allvisible." cmd = spssaux.createxmloutput(gar, visible=true) result=spssaux.getvaluesfromxmlworkspace(cmd, 'ctables', cellattrib ='text',colcategory='cat1', rowcategory='research pay',rowsubcategory='yes') result1=spssaux.getvaluesfromxmlworkspace(cmd, 'ctables', tablesubtype='chisquare', cellattrib = 'text',colcategory='status', rowcategory='research pay',rowsubcategory='sig.') output new print result[1] print result1[1] end program. *2. export output excel. output export /contents export= layers=printsetting modelviews=printsetting /xlsx documentfile='u:/report1.xlsx' operation=createfile location=startcell('c4') notescaptions=yes. this error message getting
file "<string>", line 4 gar="ctables syntaxerror: eol while scanning string literal ^ can please me code?
you have syntax error in python code. line starting gar= introducing multi-line literal, need enclose in triple quotes,
gar="""ctables
/vlabels variables=institution res_pay status display=label
/table status [c] > res_pay [c] institution [c][count f40.0, colpct.count pct40.1]
/categories variables=institution order=a key=value empty=include total=yes position=after
/categories variables=res_pay empty=include
/categories variables=status order=a key=value empty=include
/sigtest type=chisquare alpha=0.05 includemrsets=yes categories=allvisible."""
however, once these values, printing them viewer , exporting viewer, not want, since these values in table exported. seems roundabout way of doing this. perhaps if describe whole process simpler solution can found.
Comments
Post a Comment