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.

DEFINE—!ENDDEFINE 445<br />

• The macro call expands the macname macro. The argument is identified by its name, arg1,<br />

and is assigned the value V1. V1 is substituted wherever !arg1 appears in the macro body.<br />

The macro body in this example is the FREQUENCIES command.<br />

Example<br />

* A positional argument.<br />

DEFINE macname (!POSITIONAL !TOKENS(1)<br />

/!POSITIONAL !TOKENS(2))<br />

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

!ENDDEFINE.<br />

macname V1 V2 V3.<br />

• The macro definition defines macname as the macro name with two positional arguments.<br />

The first argument has one token and the second argument has two tokens. The tokens can<br />

be assigned any values in the macro call.<br />

• The macro call expands the macname macro. The arguments are identified by their positions.<br />

V1 is substituted for !1 wherever !1 appears in the macro body. V2 and V3 are substituted<br />

for !2 wherever !2 appears in the macro body. The macro body in this example is the<br />

FREQUENCIES command.<br />

Keyword Arguments<br />

Keyword arguments are called with user-defined keywords that can be specified in any order.<br />

In the macro body, the argument name is preceded by an exclamation point. On the macro<br />

call, the argument is specified without the exclamation point.<br />

• Keyword argument definitions contain the argument name, an equals sign, and the<br />

!TOKENS, !ENCLOSE, !CHAREND, or !CMDEND keyword (see “Assigning Tokens to<br />

Arguments” on p. 447).<br />

• Argument names are limited to seven characters and cannot match the character portion<br />

of a macro keyword, such as DEFINE, TOKENS, CHAREND, and so forth. See the syntax<br />

chart on p. 440 for a list of macro keywords for the program.<br />

• The keyword !POSITIONAL cannot be used in keyword argument definitions.<br />

• Keyword arguments do not have to be called in the order they were defined.<br />

Example<br />

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

* Macro definition.<br />

DEFINE macdef2 (arg1 = !TOKENS(1)<br />

/arg2 = !TOKENS(1)<br />

/arg3 = !TOKENS(1))<br />

frequencies variables = !arg1 !arg2 !arg3.<br />

!ENDDEFINE.<br />

* Macro call.<br />

macdef2 arg1=V1 arg2=V2 arg3=V3.<br />

macdef2 arg3=V3 arg1=V1 arg2=V2.

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

Saved successfully!

Ooh no, something went wrong!