Using Python with SPSS

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Python with SPSS

Manoj Arora (DEL/Abacus Analytics)

Hi,

 

I have been using SPSS for last 18 years and I have never used python with SPSS. How can I use Python and SPSS together? Do you have any book which will help me in integrating Python with SPSS?

 

 

 

Thanks & Regards

Manoj

 


http://www.imrbint.com/disclaimer.html ===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Using Python with SPSS

Bruce Weaver
Administrator
You could take a look at the tutorials on Ruben's nice site.

   http://www.spss-tutorials.com/about-us/

HTH.

.oO(I hope DM doesn't notice that I'm aiding & abetting a would-be Pythonista!)  



Manoj Arora (DEL/Abacus Analytics) wrote
Hi,

 

I have been using SPSS for last 18 years and I have never used python with SPSS. How can I use Python and SPSS together? Do you have any book which will help me in integrating Python with SPSS?

 

 

 

Thanks & Regards

Manoj

 



http://www.imrbint.com/disclaimer.html

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Using Python with SPSS

Manoj Arora (DEL/Abacus Analytics)
In reply to this post by Manoj Arora (DEL/Abacus Analytics)

Hi,

 

I have written macro in which I am generating tables for City and within city Telecom Operators. For some cities some operators do not exist so my data file contains 0 cases and it generates all the tables with error messages. Is there way to avoid the running of macro for non-existing of cases.

 

Thanks & Regards

Manoj

 


http://www.imrbint.com/disclaimer.html ===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Using Python with SPSS

Bruce Weaver
Administrator
What does this have to do with "Using Python with SPSS"?  You'll be more likely to get responses if you start a new thread (with an informative subject line) for a new question.  And note that replying to an old post and simply changing the subject line still louses up the threading in the Nabble archive.  You need to start a new topic/thread.

;-)


Manoj Arora (DEL/Abacus Analytics) wrote
Hi,

 

I have written macro in which I am generating tables for City and within city Telecom Operators. For some cities some operators do not exist so my data file contains 0 cases and it generates all the tables with error messages. Is there way to avoid the running of macro for non-existing of cases.

 

Thanks & Regards

Manoj

 



http://www.imrbint.com/disclaimer.html

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Using Python with SPSS

Albert-Jan Roskam-2
In reply to this post by Manoj Arora (DEL/Abacus Analytics)
easy:

file handle input /name = "\\server\share\dir\subdir\foo.sav".
begin program.

import spss

def process(telecom_operators, cities):

    for telecom_operator in telecom_operators:
        for city in cities:
            get file = input.

            cmd = "select if (city eq '%' and operator eq '%s')."

            spss.Submit(cmd % (city, telecom_operator))
            spss.Submit("execute.") # needed here

            if not spss.GetCaseCount():  # skipping takes place here

                continue
            spss.Submit("ctables ....blah blah.")
process(["Verizon", "Orange"], ["New York", "Madrid", "Capetown"])
end program.

Regards,

Albert-Jan




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a

fresh water system, and public health, what have the Romans ever done for us?






>________________________________
> From: Manoj Arora (DEL/Abacus Analytics) <[hidden email]>
>To: [hidden email]
>Sent: Thursday, September 4, 2014 11:42 AM
>Subject: Re: [SPSSX-L] Using Python with SPSS
>
>
>
>Hi,
>
>I have written macro in which I am generating tables for City and within city Telecom Operators. For some cities some operators do not exist so my data file contains 0 cases and it generates all the tables with error messages. Is there way to avoid the running of macro for non-existing of cases.
>
>Thanks & Regards
>Manoj
>
>http://www.imrbint.com/disclaimer.html
=====================
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
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

=====================
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