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 (September 2008)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 10 Sep 2008 17:19:12 +0100
Reply-To:     J Sutar <jsutar@gmail.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         J Sutar <jsutar@gmail.com>
Subject:      Re: loop through a list of
Comments: To: "Peck, Jon" <peck@spss.com>
In-Reply-To:  <5CFEFDB5226CB54CBB4328B9563A12EE09CF6CEB@hqemail2.spss.com>
Content-Type: text/plain; charset=ISO-8859-1

Thanks Jon,

I now have the following program (see below) but as it stands it enters the variable name in the TITLE spss command. I would like to change this so that it enters the variable label?

BEGIN PROGRAM. import spss, spssaux vardict=spssaux.VariableDict(pattern=r"w12m") for v in vardict: spss.Submit(""" TITLE %s

LOGISTIC REGRESSION VARIABLES %s /METHOD = FSTEP(LR) age_15_24 age_25_34 age_35_44 age_45_54 age_55_64 age_65x soc_a soc_b soc_c1 soc_c2 soc_d soc_e /SAVE = PRED(P_%s) /PRINT = SUMMARY /CRITERIA = PIN(.05) POUT(.10) ITERATE(20) CUT(.5) . """ % (v,v,v)) END PROGRAM.

Many Thanks

Jigs 2008/9/9 Peck, Jon <peck@spss.com>

> If you use the Python spssaux VariableDict object, you can specify a prefix > to it and then iterate over the variables in the dictionary. Something like > > begin program. > import spss, spssaux > vardict=spssaux.VariableDict(pattern=r"w12") > for v in vardict: > spss.Submit("LOGISTIC REGRESSION VARIABLES %s /METHOD ..." % v) > end program. > > HTH > > -----Original Message----- > From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of J > Sutar > Sent: Tuesday, September 09, 2008 9:54 AM > To: SPSSX-L@LISTSERV.UGA.EDU > Subject: [SPSSX-L] loop through a list of > > Hi, > > I would like to create program which performs similarly to the macro > below. I would like to adjust it such that it picks up all variables in > the > dataset that start with a certain prefix, for example w12m. The dependent > variables start from w12m01 to w12m85, due to the leading zero of the first > 9 dependent variables I struggled to create a SPSS macro. Perhaps a python > solution would work better? > > Please not also that there are certain variables missing so for example > w12m36 may not exist hence why I want it to search and find all variables > of > a specified prefix. > > Many thanks for your help. > Jigs > > > > * > > http://www.spsstools.net/Syntax/RegressionRepeatedMeasure/LogisticRegressionByMacro.txt > * I want to perform a logistic regression ten times for ten different > variables without having to copy > * and paste the syntax nine times. > * Solution posted by rlevesque@videotron.ca to newsgroup on 2001/05/10. > > GET FILE='c:\program files\spss\employee data.sav'. > > * Define macro to do the job. > */////////////////////////. > DEFINE !logist(dv=!TOKENS(1) /iv=!CMDEND) > LOGISTIC REGRESSION VAR=!dv > /METHOD=ENTER !iv > /CRITERIA PIN(.05) POUT(.10) ITERATE(20) CUT(.5) . > !ENDDEFINE. > */////////////////////////. > > * Do logistic regression of gender using salary and educ. > !logist dv=gender iv=salary educ. > > * Do logistic regression of minority using salary and jobcat. > !logist dv=gender iv=salary educ. > > ===================== > To manage your subscription to SPSSX-L, send a message to > LISTSERV@LISTSERV.UGA.EDU (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 LISTSERV@LISTSERV.UGA.EDU (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


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