Hi All,
being a beginner with SPSS syntax I have a simple question. I want to do the same analysis for all dependent variables in my dataset. How to use loop or do repeat command in order to repeat the analysis for a defined set of variables? Here is the example: * dependent variables list orientation_mean evaluation_mean control_mean Outcome_satisfaction Process_satisfaction Influence_strength_other *analysis to be repeated DATASET ACTIVATE xx. MIXED orientation_mean BY Medium /CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001) HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE) /FIXED=Medium | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION TESTCOV /RANDOM=INTERCEPT | SUBJECT(dyad_no) COVTYPE(VC). thank you!! Karolina |
You can not use DO REPEAT, but here are a few other options:
- write a macro and pass the list as a parameter - use Python, loop over the list and use spss.Submit - reshape the variables using VARSTOCASES, and then use SPLIT FILE to run the results for each model. The last option has the advantage you can actually fit some multivariate models. Example (untested) below. ***************************. VARSTOCASES /MAKE Dep FROM orientation_mean evaluation_mean control_mean Outcome_satisfaction Process_satisfaction Influence_strength_other /INDEX LabDep (Dep). SORT CASES BY LabDep. SPLIT FILE BY LabDep. *Probably OMS here to capture the model output. DATASET ACTIVATE xx. MIXED Dep BY Medium /CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001) HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE) /FIXED=Medium | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION TESTCOV /RANDOM=INTERCEPT | SUBJECT(dyad_no) COVTYPE(VC). SPLIT FILE OFF. ***************************. |
A macro solution woulde be (untested): * =================================================================================. * macro definition. DEFINE @myanalysis(!POS !CMDEND) !DO !dv !IN (!1) MIXED !dv BY Medium /CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001) HCONVERGE(0,ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE) /FIXED=Medium | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION TESTCOV /RANDOM=INTERCEPT | SUBJECT(dyad_no) COVTYPE(VC). !DOEND !ENDDEFINE. DATASET ACTIVATE xx. * macro call. @myanalysis orientation_mean evaluation_mean control_mean Outcome_satisfaction Process_satisfaction Influence_strength_other. * =================================================================================. !1 stands for the list of dependent variables, !dv for each element of this list GL, Mario Andy W <[hidden email]> schrieb am 13:47 Mittwoch, 6.Mai 2015: You can not use DO REPEAT, but here are a few other options: - write a macro and pass the list as a parameter - use Python, loop over the list and use spss.Submit - reshape the variables using VARSTOCASES, and then use SPLIT FILE to run the results for each model. The last option has the advantage you can actually fit some multivariate models. Example (untested) below. ***************************. VARSTOCASES /MAKE Dep FROM orientation_mean evaluation_mean control_mean Outcome_satisfaction Process_satisfaction Influence_strength_other /INDEX LabDep (Dep). SORT CASES BY LabDep. SPLIT FILE BY LabDep. *Probably OMS here to capture the model output. DATASET ACTIVATE xx. MIXED Dep BY Medium /CRITERIA=CIN(95) MXITER(100) MXSTEP(10) SCORING(1) SINGULAR(0.000000000001) HCONVERGE(0, ABSOLUTE) LCONVERGE(0, ABSOLUTE) PCONVERGE(0.000001, ABSOLUTE) /FIXED=Medium | SSTYPE(3) /METHOD=REML /PRINT=SOLUTION TESTCOV /RANDOM=INTERCEPT | SUBJECT(dyad_no) COVTYPE(VC). SPLIT FILE OFF. ***************************. ----- Andy W [hidden email] http://andrewpwheeler.wordpress.com/ -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/simple-q-about-loops-in-syntax-tp5729495p5729496.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== 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
Mario Giesel
Munich, Germany |
In reply to this post by Karolina
Thanks guys, both methods work just fine; Mario's proposition's a bit more intuitive for me. I see that I need to read more on macros - it cuts off loads of nuissance clicking. !. Can you recommend some good online reading for the medium-stats-aware beginners?
Anyway if you had a little more spare time, could you explain this line for me? what do POS, CMDEND, IN mean?: DEFINE @myanalysis(!POS !CMDEND) !DO !dv !IN (!1) Greetings and many thanks to both of you :) k |
Administrator
|
Karolina, in the Command Syntax Reference manual (aka the "fine manual", or FM), Look up the following, and consider the examples that are shown:
DEFINE-!ENDDEFINE > Macro Arguments > Positional Arguments DEFINE-!ENDDEFINE > Macro Arguments > Assigning Tokens to Arguments DEFINE-!ENDDEFINE > Looping Constructs > List Processing Loop HTH.
--
Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM." PLEASE NOTE THE FOLLOWING: 1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. 2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/). |
In reply to this post by Karolina
At 08:39 AM 5/6/2015, Karolina wrote:
I see that I need to read more on macros - it cuts off loads of nuisance clicking. !. Can you recommend some good online reading for the medium-stats-aware beginners? As Bruce Weave has stated, the Command Syntax Reference article on command DEFINE/!ENDDEFINE is the indispensable reference work. Another source, a tutorial rather than just a reference work, is chapter 6 of Levesque, Raynald, SPSSĀ® Programming and Data Management, 2nd Edition; SPSS Inc., Chicago, 2005. (That chapter is not part of later editions of the same work.) Since the .PDF was freely distributed, I'll feel free to send you a copy if you can't find one otherwise, and let me know off-list. ===================== 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 Bruce Weaver
the Fine Manual ;) the Bible maybe?
Thanks for all reading suggestions and materials. I'm adding Mario's explanation of the original macro for future readers to see what the code does: !POS = !POSITIONAL = a positional (not keyword) argument !CMDEND = command end, take all text till the end of the command !IN = in the set / space separated list !DO !dv = for each dependent variable in the list do ... |
Administrator
|
In addition to !POSITIONALS Macros can receive NAMED arguments.
These can be passed in a number of ways !ENCLOSE (elements of argument surrounded by a pair of characters. Ex. DEFINE !mymacro (depvar !ENCLOSE('[',']') ) !DO !v !IN (!depvar) .... !DOEND !ENDDEFINE. !mymacro depvar [a b c d]. !CHAREND: Argument is delimited by a specified character . DEFINE !mymacro2 (depvar !CHAREND ('/') /other !CMDEND). !DO !v !IN(!depvar) !IF (!v !EQ x) !THEN .... ECHO !QUOTE(!other). !IFEND !DOEND !ENDDEFINE. !mymacro2 depvar a b c / other x. ......
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |