Question regarding looping through variables

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question regarding looping through variables

Jörnkvist, Richard (Bisnode)

Dear subscribers.

 

I have a question regarding looping through variables.

 

I have created a syntax that computes statistics and outputs graphs to a PDF file. This syntax is run by an insert command as follows:

 

insert SYNTAX=INTERACTIVE FILE='H:\SPSS\IV.sps'.

 

Before running the syntax I create some “macro variables” that are passed on to the syntax above.

 

define !BinnedVar () NSCORE !enddefine.

define !OrgVar () SCORE !enddefine.

define !OrgVarQuote () "SCORE" !enddefine.

 

Is it possible to loop through a list of variables and pass them on one by one to the syntax? I give an example below.

 

* Define the variables to loop through *.

Define !variables () var1 var2 var3 var4……. !enddefine.

 

* Start of the loop *.

define !BinnedVar () !CONCAT(‘N’,!variables) !enddefine.

define !OrgVar () !variables !enddefine.

define !OrgVarQuote () !QUOTES(!variables) !enddefine.

 

* Call the syntax *.

insert SYNTAX=INTERACTIVE FILE='H:\SPSS\IV.sps'.

 

* End of the loop *.

 

I have tried to build the syntax as a macro but then I get error messages and the graphs are not outputted.

 

 

Regards,

 

─────────────────────────────────────────────────────
RICHARD JÖRNKVIST
Analytiker
Bisnode Kredit AB

BISNODE
Direkt: +46 8 5190 1106
E-post: [hidden email]
Besöksadress: Bisnode, Rosenborgsgatan 4-6, Solna
Postadress: Bisnode Kredit AB, 169 93 Solna
www.bisnode.com
twitter.com/bisnodesverige  facebook.com/bisnodesverige
─────────────────────────────────────────────────────

Ta bättre beslut i Norden Läs mer

 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Question regarding looping through variables

David Marso
Administrator

Maybe you should learn about MPRINT !DO, !EVAL and "real" macros (parameters??)!
Also do you think posting the actual error messages might be a reasonable thing to do?
Also, you would do well to describe WHAT you are actually intending to achieve !
Current 'design' is questionable at best!
---
Jörnkvist, Richard (Bisnode) wrote
Dear subscribers.

I have a question regarding looping through variables.

I have created a syntax that computes statistics and outputs graphs to a PDF file. This syntax is run by an insert command as follows:

insert SYNTAX=INTERACTIVE FILE='H:\SPSS\IV.sps'.

Before running the syntax I create some “macro variables” that are passed on to the syntax above.
.....
<SNIP mostly unworkable garbage >
I have tried to build the syntax as a macro but then I get error messages and the graphs are not outputted.


Regards,
─────────────────────────────────────────────────────
RICHARD JÖRNKVIST
Analytiker
Bisnode Kredit AB
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?"