SPSS 17 / Vista
I have been trying to adapt a python example from "Programming and Data Management for SPSS® Statistics 17.0". Page 253 The problem is to read variables from a tables (Descriptive - P.253). This example works fine with my data. Now I tried to adapt exactly the same example for a REGRESSION. But this time this doesn't work, althoug I take the exact code, that works with DESCRIPTIVE. Here is the code: I can't find the solution. BEGIN PROGRAM. import spss,spssaux spss.Submit("GET FILE='C:/<path>/file.sav'.") cmd=r"""REGRESSION /MISSING LISTWISE /STATISTICS COEFF OUTS R ANOVA /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT Bewertung /METHOD=ENTER Geschlecht Schicht Alter.""" desc_table,errcode=spssaux.CreateXMLOutput( cmd, omsid="Regression") stbw_alter=spssaux.GetValuesFromXMLWorkspace( desc_table, tableSubtype="'Coefficients'", rowCategory="Alter", colCategory="T", cellAttrib="text") if stbw_alter: print "Der Koeffizient betraegt: ", stbw_alter[0] END PROGRAM. *--------------------------------------------------------* Here is the error message: Traceback (most recent call last): File "<string>", line 21, in <module> File "C:\Python25\lib\site-packages\spssaux\spssaux.py", line 215, in getValuesFromXmlWorkspace res = spss.EvaluateXPath(tag, "/outputTree", xpath) File "C:\Python25\lib\site-packages\spss170\spss\spss.py", line 414, in EvaluateXPath raise SpssError,error spss.errMsg.SpssError: [errLevel 21] Invalid XPath expression. *---------------------------------------------------------*
Dr. Frank Gaeth
|
Notice that you have an extra set of quotes
in your getValues call, so no subtype will match.
Also, in order to select the row based on the variable name (typically it is the label appearing in the table), you need to specify that rowAttrib="varName". So you would specify rowCategory="Alter", rowAttrib="varName". That should do it. Regards, Jon Peck Senior Software Engineer, IBM [hidden email] 312-651-3435 From: drfg2008 <[hidden email]> To: [hidden email] Date: 02/19/2011 12:55 PM Subject: [SPSSX-L] python Sent by: "SPSSX(r) Discussion" <[hidden email]> SPSS 17 / Vista I have been trying to adapt a python example from "Programming and Data Management for SPSS® Statistics 17.0". Page 253 The problem is to read variables from a tables (Descriptive - P.253). This example works fine with my data. Now I tried to adapt exactly the same example for a REGRESSION. But this time this doesn't work, althoug I take the exact code, that works with DESCRIPTIVE. Here is the code: I can't find the solution. BEGIN PROGRAM. import spss,spssaux spss.Submit("GET FILE='C:/<path>/file.sav'.") cmd=r"""REGRESSION /MISSING LISTWISE /STATISTICS COEFF OUTS R ANOVA /CRITERIA=PIN(.05) POUT(.10) /NOORIGIN /DEPENDENT Bewertung /METHOD=ENTER Geschlecht Schicht Alter.""" desc_table,errcode=spssaux.CreateXMLOutput( cmd, omsid="Regression") stbw_alter=spssaux.GetValuesFromXMLWorkspace( desc_table, tableSubtype="'Coefficients'", rowCategory="Alter", colCategory="T", cellAttrib="text") if stbw_alter: print "Der Koeffizient betraegt: ", stbw_alter[0] END PROGRAM. *--------------------------------------------------------* Here is the error message: Traceback (most recent call last): File "<string>", line 21, in <module> File "C:\Python25\lib\site-packages\spssaux\spssaux.py", line 215, in getValuesFromXmlWorkspace res = spss.EvaluateXPath(tag, "/outputTree", xpath) File "C:\Python25\lib\site-packages\spss170\spss\spss.py", line 414, in EvaluateXPath raise SpssError,error spss.errMsg.SpssError: [errLevel 21] Invalid XPath expression. *---------------------------------------------------------* ----- FUB -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/python-tp3392584p3392584.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |