How to replace a list of variables with a single stand-in variable in a command syntax?

Technote (FAQ)


Question

We have a syntax like:
IF (ANY(Q1,Q2,VAR_95,VAR_112,VAR_113,VAR_114,VAR_115,VAR_125)) ANS=Q1.
EXECUTE.

And we would like to simplify it with something like:
IF (ANY(Q1,Q2,$VAR)) ANS=Q1.
EXECUTE.

Answer

This can be done with a macro:


* Define the 'stand-in' macro name as the list of variables.
DEFINE @VAR () VAR_95,VAR_112,VAR_113,VAR_114,VAR_115,VAR_125 !ENDDEFINE.

* Later, use that 'stand-in' macroname; it will expand upon execution into the desired list.
IF (ANY(Q1,Q2,@VAR)) ANS=Q1.
EXECUTE.


Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

SPSS Statistics

Software version:

19.0, 20.0, 21.0

Operating system(s):

Platform Independent

Reference #:

1649399

Modified date:

2013-09-10

Translate my page

Machine Translation

Content navigation