Date: Tue, 18 Jan 2011 00:34:40 -0800
Reply-To: Albert-Jan Roskam <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Albert-Jan Roskam <email@example.com>
Subject: Re: Python Functions Arguments
If you intend to work with regexes, the following resource is a MUST:
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: J Sutar <firstname.lastname@example.org>
Sent: Thu, January 13, 2011 2:45:03 PM
Subject: [SPSSX-L] Python Functions Arguments
I'm experimenting with python and have a few questions on how to adapt the
following macro to make it super efficient and user friendly...
import spss, spssaux
def demo (vars):
spss.Submit("""freq %(varStr)s. """ % locals())
demo(vars="gender bdate educ jobcat salary salbegin jobtime prevexp minority")
demo(vars="gender bdate educ jobcat"
"salary salbegin jobtime prevexp minority")
1. The parameter vars in the current example accepts only a list of variables
but is it possible also to input in this very same parameter (or any other work
around) a way where I can specify a regular expression match? For this example,
say, the variables starting with the letter "s" as an example?
2. I haven't looked into this into detail but I've seen other post about using
the TO conversion also can this also be built in...so potentially there could be
3 different ways of specifying the arguments for the parameter vars?
3. Is it possible specify vars without having to enclose them in quotation
4. Often the list of variables will be a long list so its necessary to allow
them to wrap over multiple lines but in a python function calls this can only be
done if each line is enclosed in quotation marks (see second macro call in
example syntax above). Is there a better work around to this?
I ask most of these questions because I'm currently in the process of converting
macros written in conventional SPSS macro syntax to python programs. In a
conventional SPSS macro call I could easily list all the variables, across
multiple lines not have to quote them. I'm trying to keep things as similar as
possible because others and I have got into a habit of calling macros in a
Many thanks in advance...