|
STATA has a set of commands that allow looping ( repetitive tasks) over
sequences of numbers or lists of variables, so rather than cutting and pasting the same command and changing one variable multiple times you can list the variables on one line and just write the task once. An example of command in STATA is "For each x of varlist Var1 Var2 Var3 Var4...{tab x time, } Does SPSS have similar command? ===================== 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 |
|
This is old syntax that was probably written for SPSS 15 or earlier, but
I believe it still works. This syntax runs a simple bar graph for each of the variables listed after the word @graphs in the last line. ** A list processing loop that will run the graph for each variable in succession. DEFINE @graphs (!POS !CHAREND('/') ) !DO !i !IN ( !1) GRAPH /BAR(SIMPLE)=PCT BY !i /TEMPLATE='L:\Survey\SPSSTemplates\BlueBarPct.sgt'. !DOEND !ENDDEFINE. @graphs RESTYLPERF REBRNDPRIC REHNDLCOMF RECOMFSTYL REBRNDSTYL RESTYLPRIC /. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Deepa Bhat Sent: Tuesday, January 27, 2009 9:47 AM To: [hidden email] Subject: Looping command in SPSS? STATA has a set of commands that allow looping ( repetitive tasks) over sequences of numbers or lists of variables, so rather than cutting and pasting the same command and changing one variable multiple times you can list the variables on one line and just write the task once. An example of command in STATA is "For each x of varlist Var1 Var2 Var3 Var4...{tab x time, } Does SPSS have similar command? ===================== 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 ---------------- Defender MX4 - QLAN ===================== 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 |
|
For repeating statistical or charting procedures for different sets of variables, you would need to either use the macro language as in the example below or a Python program using the Python plug-in. If you aren't familiar with either, I would recommend learning how to use the Python plug-in.
For transformation commands (e.g., Compute, Recode) you can use the Do Repeat command, as in: do repeat x=var1 to var10 /y=new1 to new10. compute y=x*10. end repeat. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Heidi Green Sent: Tuesday, January 27, 2009 12:24 PM To: [hidden email] Subject: Re: Looping command in SPSS? This is old syntax that was probably written for SPSS 15 or earlier, but I believe it still works. This syntax runs a simple bar graph for each of the variables listed after the word @graphs in the last line. ** A list processing loop that will run the graph for each variable in succession. DEFINE @graphs (!POS !CHAREND('/') ) !DO !i !IN ( !1) GRAPH /BAR(SIMPLE)=PCT BY !i /TEMPLATE='L:\Survey\SPSSTemplates\BlueBarPct.sgt'. !DOEND !ENDDEFINE. @graphs RESTYLPERF REBRNDPRIC REHNDLCOMF RECOMFSTYL REBRNDSTYL RESTYLPRIC /. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Deepa Bhat Sent: Tuesday, January 27, 2009 9:47 AM To: [hidden email] Subject: Looping command in SPSS? STATA has a set of commands that allow looping ( repetitive tasks) over sequences of numbers or lists of variables, so rather than cutting and pasting the same command and changing one variable multiple times you can list the variables on one line and just write the task once. An example of command in STATA is "For each x of varlist Var1 Var2 Var3 Var4...{tab x time, } Does SPSS have similar command? ===================== 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 ---------------- Defender MX4 - QLAN ===================== 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 |
|
In reply to this post by Deepa Bhat
Yes. There are actually a few looping commands available in SPSS, namely,
LOOP, DO REPEAT and !DO (which is used within macro definitions !DEFINE-!ENDDEFINE). If you look up these commands in the command syntax reference pdf, you'll get a better idea which is appropriate for your needs. HTH, Jigs On 27 Jan 2009, 6:10 PM, "Deepa Bhat" <[hidden email]> wrote: STATA has a set of commands that allow looping ( repetitive tasks) over sequences of numbers or lists of variables, so rather than cutting and pasting the same command and changing one variable multiple times you can list the variables on one line and just write the task once. An example of command in STATA is "For each x of varlist Var1 Var2 Var3 Var4...{tab x time, } Does SPSS have similar command? ===================== 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 |
|
In reply to this post by Deepa Bhat
in help see
DO REPEAT LOOP SPLIT FILE. Also most procedures allow use of list of variables. look for the word varlist in the syntax summaries. FREQUENCIES VARS = AGE GENDER IQ ITEM01 TO ITEM11 ... CROSSTABS TABLES = CANDIDATE1 TO CANDIDATE5 BY AGE PARTY REGION... MULT RESPONSE GROUPS = magazines 'magazines read' mag1 to mag5 (1,11)... you may also mean something like MACROS or PYTHON which can also be found under the help tab. Art Kendall Social Research Consultants Deepa Bhat wrote: > STATA has a set of commands that allow looping ( repetitive tasks) over > sequences of numbers or lists of variables, so rather than cutting and > pasting the same command and changing one variable multiple times you > can list the variables on one line and just write the task once. An > example of command in STATA is "For each x of varlist Var1 Var2 Var3 > Var4...{tab x time, } > > Does SPSS have similar command? > > ===================== > 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
Art Kendall
Social Research Consultants |
|
In reply to this post by Deepa Bhat
Hello
When I have to run many analyses of the same type I use the following syntax. It includes a macro which allows you just to insert the independant and dependant variables in a list. Furthermore, it is combined with an OMS comand and save translate outfile. This is specific for logistic regression but it easily can be adjusted for other types of analyses. Sakari -- Sakari Lemola, Ph.D. Department of Psychology University of Basel **********************************. *oms command with indexing the regressions in the new file PRESERVE. SET TVARS NAMES. oms select tables /destination format = sav numbered = "Table_Number" outfile = 'yourpath/results_temp.sav' /if commands = ['Logistic regression'] subtypes = ['Block 1: Method = Enter' 'Variables in the Equation'] /tag = "reg". *several Logistic regressions get file 'yourpath/yourdata.sav'. *////////////////////. DEFINE !Logreg1 (indepvars=!charend ('/') /depvars=!CMDEND) !DO !depvar !IN (!depvars) !DO !indepvar !IN (!indepvars) LOGISTIC REGRESSION Variables = !depvar /method = enter !indepvar controlvar1 controlvar2 /PRINT=CI(95) . !DOEND !DOEND !ENDDEFINE. */////////////////// !Logreg1 indepvars= independantvar1 independantvar2 / depvars= dependentvar1 dependantvar2 . EXECUTE. */insert the critical independant variables after "indepvars=" /* */insert the critical dependant variables after "depvars=" /* omsinfo. omsend tag = ["reg"]. RESTORE. ************ *Open the new file with the results get file 'yourpath/results/results_temp.sav'. IF ANY(Var2, 'independantvar1', 'independantvar2') var2n = 1. EXECUTE. FILTER OFF. USE ALL. SELECT IF (var2n = 1). EXECUTE. SAVE TRANSLATE OUTFILE='yourpath/results1.sav' /TYPE=XLS /MAP /REPLACE /FIELDNAMES /CELLS=VALUES /KEEP= ExpB Upper Lower Sig . **********************************. Am 27.1.2009 19:46 Uhr schrieb "Deepa Bhat" unter <[hidden email]>: > STATA has a set of commands that allow looping ( repetitive tasks) over > sequences of numbers or lists of variables, so rather than cutting and > pasting the same command and changing one variable multiple times you > can list the variables on one line and just write the task once. An > example of command in STATA is "For each x of varlist Var1 Var2 Var3 > Var4...{tab x time, } > > Does SPSS have similar command? > > ===================== > 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 |
