27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

446 DEFINE—!ENDDEFINE<br />

• Three arguments are defined: arg1, arg2, and arg3, each with one token. In the first macro<br />

call, arg1 is assigned the value V1, arg2 is assigned the value V2, and arg3 is assigned the<br />

value V3. V1, V2, and V3 are then used as the variables in the FREQUENCIES command.<br />

• The second macro call yields the same results as the first one. With keyword arguments,<br />

you do not need to call the arguments in the order in which they were defined.<br />

Positional Arguments<br />

Positional arguments must be defined in the order in which they will be specified on the<br />

macro call. In the macro body, the first positional argument is referred to by !1, the second<br />

positional argument defined is referred to by !2, and so on. Similarly, the value of the first<br />

argument in the macro call is assigned to !1, the value of the second argument is assigned to<br />

!2, and so on.<br />

• Positional arguments can be collectively referred to in the macro body by specifying !*.<br />

The !* specification concatenates arguments, separating individual arguments with a<br />

blank.<br />

Example<br />

DATA LIST FILE=MAC / V1 1-2 V2 4-5 V3 7-8.<br />

* Macro definition.<br />

DEFINE macdef (!POS !TOKENS(1)<br />

/!POS !TOKENS(1)<br />

/!POS !TOKENS(1))<br />

frequencies variables = !1 !2 !3.<br />

!ENDDEFINE.<br />

* Macro call.<br />

macdef V1 V2 V3.<br />

macdef V3 V1 V2.<br />

• Three positional arguments with one token each are defined. The first positional argument<br />

is referred to by !1 on the FREQUENCIES command, the second by !2, and the third<br />

by !3.<br />

• When the first call expands the macro, the first positional argument (!1) is assigned the<br />

value V1, the second positional argument (!2) is assigned the value V2, and the third positional<br />

argument (!3) is assigned the value V3.<br />

• In the second call, the first positional argument is assigned the value V3, the second positional<br />

argument is assigned the value V1, and the third positional argument is assigned the<br />

value V2.<br />

Example<br />

DEFINE macdef (!POS !TOKENS(3))<br />

frequencies variables = !1.<br />

!ENDDEFINE.<br />

macdef V1 V2 V3.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!