Converting macro into python

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

Converting macro into python

BBH123
Hi,

After trying multiple SPSS extension commands that never quite gave me what I want I've given up and have decided to completely convert my (very long) macro into Python. Unfortunately I am not a programmer so this is going to be quite a job I think!

I've started to read: http://docs.python.org/tutorial/index.html - The Python Tutorial and Programming and Data Management for PASW Statistics 18. However so far I've not gotten anywhere with ideas for re-writing my macro? Is the general consensus that I actually use the syntax itself and surround it with 'BEGIN PROGRAM' 'END PROGRAM'?

For example, is it actually possible to generate a custom table or a graph in SPSS using just python?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Converting macro into python

Jon K Peck
Get the Programming and Data Management Book (pdf) from the SPSS Community website.  It has many examples of doing typical Statistics tasks with programmability.

HTH,

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        BBH123 <[hidden email]>
To:        [hidden email]
Date:        01/11/2012 05:24 AM
Subject:        [SPSSX-L] Converting macro into python
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi,

After trying multiple SPSS extension commands that never quite gave me what
I want I've given up and have decided to completely convert my (very long)
macro into Python. Unfortunately I am not a programmer so this is going to
be quite a job I think!

I've started to read:
http://docs.python.org/tutorial/index.html - The
Python Tutorial and Programming and Data Management for PASW Statistics 18.
However so far I've not gotten anywhere with ideas for re-writing my macro?
Is the general consensus that I actually use the syntax itself and surround
it with 'BEGIN PROGRAM' 'END PROGRAM'?

For example, is it actually possible to generate a custom table or a graph
in SPSS using just python?

Thanks

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Converting-macro-into-python-tp5136703p5136703.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


Reply | Threaded
Open this post in threaded view
|

Re: Converting macro into python

Bruce Weaver
Administrator
In reply to this post by BBH123
If the macro works, why convert it?

BBH123 wrote
Hi,

After trying multiple SPSS extension commands that never quite gave me what I want I've given up and have decided to completely convert my (very long) macro into Python. Unfortunately I am not a programmer so this is going to be quite a job I think!

I've started to read: http://docs.python.org/tutorial/index.html - The Python Tutorial and Programming and Data Management for PASW Statistics 18. However so far I've not gotten anywhere with ideas for re-writing my macro? Is the general consensus that I actually use the syntax itself and surround it with 'BEGIN PROGRAM' 'END PROGRAM'?

For example, is it actually possible to generate a custom table or a graph in SPSS using just python?

Thanks
--
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: Converting macro into python

BBH123
The macro almost works. The part I cannot get right is the output!

My macro exports a large number of reports (one for each course). I wanted my reports in word/excel/pdf, basically something that non-SPSS users could access. However the formatting for the output export is extremely limited, with word/excel you cannot insert page breaks or headings and the whole thing looks a mess, and with pdf you cannot edit it's orientation/margins etc as 'Page Attributes' and 'Page Set Up' cannot be edited using syntax.

I am hoping that by converting to python I can get around these issues, although it's an uphill struggle currently, I've not managed to re-write anything yet and I've been working on it for 3 days now!

Reply | Threaded
Open this post in threaded view
|

Re: Converting macro into python

Albert-Jan Roskam
Hi,
 
Have you tried using the SPSSINC MODIFY OUTPUT extension command for the final formatting bit of your code? Or are you using Spss <v17?
 
Cheers!!
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: BBH123 <[hidden email]>
To: [hidden email]
Sent: Wednesday, January 11, 2012 2:59 PM
Subject: Re: [SPSSX-L] Converting macro into python

The macro almost works. The part I cannot get right is the output!

My macro exports a large number of reports (one for each course). I wanted
my reports in word/excel/pdf, basically something that non-SPSS users could
access. However the formatting for the output export is extremely limited,
with word/excel you cannot insert page breaks or headings and the whole
thing looks a mess, and with pdf you cannot edit it's orientation/margins
etc as 'Page Attributes' and 'Page Set Up' cannot be edited using syntax.

I am hoping that by converting to python I can get around these issues,
although it's an uphill struggle currently, I've not managed to re-write
anything yet and I've been working on it for 3 days now!



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Converting-macro-into-python-tp5136703p5136876.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


Reply | Threaded
Open this post in threaded view
|

Re: Converting macro into python

BBH123
Hi,

I used the SPSSINC MODIFY OUTPUT when I was trying to use word but it had absolutely no effect on the page breaks.

I'm now attempting to use it to export to PDF instead, however for some reason my titles (syntax: Title) do not appear in my pdf file at all? I have also been using STATS OUTPUT ATTRS to rotate my pdf orientation to landscape. I've attempted to use variations of visibility, but even if I allow everything to be visible, my page titles do not exist. I wonder if it's because of the orientation.

Thanks,

Bethany