LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2011)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 18 Jan 2011 00:34:40 -0800
Reply-To:     Albert-Jan Roskam <>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Albert-Jan Roskam <>
Subject:      Re: Python Functions Arguments
Comments: To: J Sutar <>
In-Reply-To:  <>
Content-Type: multipart/alternative;

Hi Jignesh, If you intend to work with regexes, the following resource is a MUST: ;-)  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: J Sutar <> To: SPSSX-L@LISTSERV.UGA.EDU Sent: Thu, January 13, 2011 2:45:03 PM Subject: [SPSSX-L] Python Functions Arguments Hello, 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... BEGIN PROGRAM. import spss, spssaux def demo (vars):     varList=vars.split()     vardict= spssaux.VariableDict(varList)     varStr=" ".join(varList)     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") END PROGRAM. 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 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 marks? 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 particular way... Many thanks in advance... Jignesh


Back to: Top of message | Previous page | Main SPSSX-L page