|
I would like to cycle/loop through a list of words (i.e., not variables)
For example: A list of words I would like to cycle through include <name>=='conseq context' This would then go into this loop: GET FILE='<name>_complete.sav'. SAVE TRANSLATE OUTFILE='<name>.dta' /TYPE=STATA /VERSION=8 /EDITION=INTERCOOLED /MAP /REPLACE . DATASET CLOSE *. execute. Finish loop rather than (the current form below GET FILE='conseq_complete.sav'. SAVE TRANSLATE OUTFILE='conseq.dta' /TYPE=STATA /VERSION=8 /EDITION=INTERCOOLED /MAP /REPLACE . execute. GET FILE='context_complete.sav'. SAVE TRANSLATE OUTFILE=context.dta' /TYPE=STATA /VERSION=8 /EDITION=INTERCOOLED /MAP /REPLACE . execute. Cheers ------------------------------------------ DISCLAIMER: This message (including any attachments) is intended solely for the addressee(s) named and may contain confidential or privileged information. If you are not the intended recipient, please delete it and notify the sender. Views expressed in this message are those of the individual sender,and are not necessarily the views of the Turning Point Alcohol and Drug Centre Inc (ABN: 17 302 055 629). <a href="http://www.turningpoint.org.au">Turning Point Alcohol and Drug Centre Inc</a> Although this message and any attachments have been scanned for viruses by 'Trend Micro InterScan' at the time of sending, you are advised to rescan on receipt. The whole or parts of this email may be subject to copyright of Turning Point Alcohol and Drug Centre Inc (ABN: 17 302 055 629), and/or third parties. You can only re-transmit, distribute or use the material if you are authorised to do so. Please consider the environment before printing this email or attachments. ===================== 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 |
|
Hi,
You can use Python or macro, but the notation is much easier in Python. Python is more flexible/versatile. Python is a starting point, whereas macro is an end point. Cheers!! Albert-Jan * python. import spss def mynames (names): for name in names: spss.Submit(""" GET FILE='%s_complete.sav'. SAVE TRANSLATE OUTFILE='%s.dta' /TYPE=STATA /VERSION=8 /EDITION=INTERCOOLED /MAP /REPLACE . DATASET CLOSE.""" % (name, name)) mynames (names = ["name1", "name2", "name3"]) * macro. def mynames (names = !cmdend). !do !names !in !names. GET FILE=!quote(!concat(!name,'_complete.sav')). SAVE TRANSLATE OUTFILE=!quote(!concat(!name,'.dta')) /TYPE=STATA /VERSION=8 /EDITION=INTERCOOLED /MAP /REPLACE . DATASET CLOSE.""" % (name, name)) !enddefine. mynames names = name1 name2 name3 --- On Tue, 6/16/09, Jason Ferris <[hidden email]> wrote: > From: Jason Ferris <[hidden email]> > Subject: cycle through a list of words > To: [hidden email] > Date: Tuesday, June 16, 2009, 7:12 AM > I would like to cycle/loop through a > list of words (i.e., not variables) > > For example: > A list of words I would like to cycle through include > <name>=='conseq > context' > This would then go into this loop: > > GET FILE='<name>_complete.sav'. > SAVE TRANSLATE OUTFILE='<name>.dta' > /TYPE=STATA /VERSION=8 > /EDITION=INTERCOOLED /MAP /REPLACE . > DATASET CLOSE *. > execute. > > Finish loop rather than (the current form below > > GET FILE='conseq_complete.sav'. > SAVE TRANSLATE OUTFILE='conseq.dta' > /TYPE=STATA /VERSION=8 > /EDITION=INTERCOOLED /MAP /REPLACE . > execute. > > GET FILE='context_complete.sav'. > SAVE TRANSLATE OUTFILE=context.dta' > /TYPE=STATA /VERSION=8 > /EDITION=INTERCOOLED /MAP /REPLACE . > execute. > > > Cheers > > ------------------------------------------ > DISCLAIMER: This message (including any attachments) is > intended solely for the addressee(s) named and may contain > confidential or privileged information. > If you are not the intended recipient, please delete it and > notify the sender. > Views expressed in this message are those of the individual > sender,and are not necessarily the views of the Turning > Point Alcohol and Drug Centre Inc (ABN: 17 302 055 629). > > <a href="http://www.turningpoint.org.au">Turning Point > Alcohol and Drug Centre Inc</a> > > Although this message and any attachments have been scanned > for viruses by 'Trend Micro InterScan' at the time of > sending, > you are advised to rescan on receipt. > > The whole or parts of this email may be subject to > copyright of Turning Point Alcohol and Drug Centre Inc (ABN: > 17 302 055 629), and/or third parties. > You can only re-transmit, distribute or use the material if > you are authorised to do so. > > Please consider the environment before printing this email > or attachments. > > ===================== > 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 > ===================== 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 |
| Free forum by Nabble | Edit this page |
