Date: Sat, 24 Dec 2005 09:30:25 -0600
Reply-To: "Peck, Jon" <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Peck, Jon" <email@example.com>
Content-Type: text/plain; charset="utf-8"
Although I am a very big fan of the Python integration into SPSS, I admit to not being a disinterested party. However, I'd like to point out one thing about the issue of passing arguments to Python programs. This is a natural thing to think of doing if you start with an SPSS syntax orientation and want to incorporate some of the programmability features. But it is very easy to invert the problem and eliminate the need for this altogether.
You might consider making your syntax file entirely into a Python program, keeping SPSS syntax where needed and submitting it with the Python spss.Submit api. Then write Python modules with functions and methods that support all the argument passing facilities of the Python language. This way, all the program logic is Python code, and SPSS syntax is used for procedures, transformations, etc.
There is a topic on the Code Center (forums.spss.com/code_center) that discusses how to convert SPSS syntax into Python code. It is extremely easy. You can also achieve most of the effects of SaxBasic scripting with Python programs via the Viewer module on the Code Center, but that requires transcribing your Sax Basic code into Python code. Although this is not terribly difficult, there are a few pitfalls to watch out for. There is some information in the FAQ on the Code Center on this, but I plan to add more information over the next few weeks on this.
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Michael
Sent: Wednesday, December 14, 2005 8:38 AM
Subject: [SPSSX-L] Python and SPSS syntax – do they behave like one single language?
maybe some of you are also thinking about using python for their SPSS
programming (python is more or less integrated in SPSS 14). I would enjoy
some discussion about the use of it.
My hope is that syntax and python might integrate so well that they behave
as one single programming language (which is, in my view, not the case with
syntax and Sax Basic). A promising thing is that you can directly submit
variable values from python to SPSS.
On the other hand, apparently you cannot do the same thing the other way
round, i.e. with macro variables. There seems to be a solution to the
problem (http://www.spsstools.net/Python/PassAnArgumentToPython.SPS), which
involves writing to an external file and rereading it. Personally I am
afraid of this method, because I often had problems with it (i.e. sometimes
the file could not be opened) and I find it makes it more difficult to read
and understand the code. But I wonder if it is at all necessary to pass
arguments to python, because if you abstain from macros I don ´t see the
need for arguments to be passed to python (apart from macro variables
python can access all other SPSS objects directly, I understand).
Well, as you see, I find it quite hard to tell in advance, how well python
works with SPSS and what problems might appear. I do not want to spend a
lot of time and money (for upgrading to SPSS 14) and then discover that I
could as well have stack to macros and Sax Basic. I am looking very much
forward to your thoughts and comments.