|
I recently started to work with SPSS 18. At the same time I am learning
how to use SPSS with Python. Specifically, I am trying to manipulate SPSS output with SpssClient. I wrote the following Python script. I then went to Edit â Options -- Scripts -- Regressions and selected the script as a Coefficients Table autoscript. I want to display the last model in the coefficients table when I select the stepwise option when running the regression command. Up until this point I am only able to change the output so that the first model is displayed. It seems to me that I am probably on the right track with lines 1 to 7 and lines 11 to 12. I am foundering with lines 8 to 10. 1 import SpssClient 2 SpssClient.StartClient() 3 SpssScriptContext = SpssClient.GetScriptContext() 4 SpssOutputItem = SpssScriptContext.GetOutputItem() 5 SpssPivotTable = SpssOutputItem.GetSpecificType() 6 SpssPivotMgr = SpssPivotTable.PivotManager() 7 SpssDimension = SpssPivotMgr.GetRowDimension(1) 8 NumCategories = SpssDimension.GetNumCategories() 9 print "Number Categories", NumCategories 10 SpssDimension.SetCurrentCategory(NumCategories) 11 SpssDimension.MoveToLayer(0) 12 SpssClient.StopClient() I have three questions: 1) What do I need to change in the above script to get it to do what I want it to do? 2) Is using SpssClient the best way to achieve this or should I be using spssaux or some other Python extension for SPSS? 3) What is a good way to learn how to use SpssClient? I am spending a fair amount of time studying the PASW® Statistics Scripting Guide, which is available at Help -- Programmability -- Scripting. However, it seems to be taking me a long time to learn how to master new commands. Are there some example scripts somewhere? Is there a guide to learning the SpssClient rather than the Scripting Guide, which seems more like a reference text to me? Thank you, Warren Chrusciel Municipal Property Assessment Corporation 1420 Blair Place, Suite 300 Ottawa, Ontario K1J 9L8 (613) 742-1001 ext. 2201 ===================== 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 |
|
Jon Peck SPSS, an IBM Company [hidden email] 312-651-3435
I recently started to work with SPSS 18. At the same time I am learning how to use SPSS with Python. Specifically, I am trying to manipulate SPSS output with SpssClient. I wrote the following Python script. I then went to Edit – Options -- Scripts -- Regressions and selected the script as a Coefficients Table autoscript. I want to display the last model in the coefficients table when I select the stepwise option when running the regression command. Up until this point I am only able to change the output so that the first model is displayed. It seems to me that I am probably on the right track with lines 1 to 7 and lines 11 to 12. I am foundering with lines 8 to 10. 1 import SpssClient 2 SpssClient.StartClient() 3 SpssScriptContext = SpssClient.GetScriptContext() 4 SpssOutputItem = SpssScriptContext.GetOutputItem() 5 SpssPivotTable = SpssOutputItem.GetSpecificType() 6 SpssPivotMgr = SpssPivotTable.PivotManager() 7 SpssDimension = SpssPivotMgr.GetRowDimension(1) 8 NumCategories = SpssDimension.GetNumCategories() 9 print "Number Categories", NumCategories 10 SpssDimension.SetCurrentCategory(NumCategories) 11 SpssDimension.MoveToLayer(0) 12 SpssClient.StopClient() I have three questions: 1) What do I need to change in the above script to get it to do what I want it to do? >>>My first suggestion would be to try the SPSSINC MODIFY TABLES extension command from Developer Central. It can take plugin functions that are usually very short, because the command has done all the navigation and boiler plate stuff, so you can go to work directly on the relevant table or cell. In this case, there is a function in the customstylefunctions.py module included with that command for hiding all but the final model in Regression. Take a look at that and adapt if it isn't exactly what you want. There are also little pivoting functions there. These may help you to master the scripting apis as well. With your script, be careful about the numbering. It's different in the PivotManager from the other apis. 2) Is using SpssClient the best way to achieve this or should I be using spssaux or some other Python extension for SPSS? 3) What is a good way to learn how to use SpssClient? I am spending a fair amount of time studying the PASW® Statistics Scripting Guide, which is available at Help -- Programmability -- Scripting. However, it seems to be taking me a long time to learn how to master new commands. Are there some example scripts somewhere? Is there a guide to learning the SpssClient rather than the Scripting Guide, which seems more like a reference text to me? >>> There are something like 350 apis in SpssClient, so mastering them is a significant task. The Scripting manual does have simple examples, but it certainly doesn't do a Tutorial for everything. However, with the SPSSINC MODIFY TABLES and SPSSINC MODIFY OUTPUT, a great many things that you needed scripting for can now be done with regular syntax, or at least just snippets of scripting code. Thank you, Warren Chrusciel Municipal Property Assessment Corporation 1420 Blair Place, Suite 300 Ottawa, Ontario K1J 9L8 (613) 742-1001 ext. 2201 ===================== 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 |
|
In reply to this post by Warren Chrusciel
I downloaded the SPSSINC MODIFY TABLES zip file to my computer and
unzipped the contents to the suitable directory. I then installed the custom dialog package using Utilities>Custom Dialogs>Install Custom Dialog. I am able to generate the following syntax using Utilities>Modify Table Appearance: SPSSINC MODIFY TABLES subtype="'Coefficients'" SELECT="Model" DIMENSION= ROWS LEVEL = -1 PROCESS = ALL /STYLES APPLYTO=BOTH CUSTOMFUNCTION="customstylefunctions.hideNonfinalRows". However, I don't understand all the option that are available on the Modify Table Appearance command. The command seems to be accessing the correct table but as I change options it is still displaying all rows and not just those of the final regression. Which option(s) do I need to change in SPSSINC MODIFY TABLES? Thanks for all the help up to this point. Warren Chrusciel Municipal Property Assessment Corporation 1420 Blair Place, Suite 300 Ottawa, Ontario K1J 9L8 ===================== 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 |
