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.

444 DEFINE—!ENDDEFINE<br />

Example<br />

• The macro is called three times. Every time check is encountered, it is replaced with the<br />

command sequence SPLIT FILE, FREQUENCIES, DESCRIPTIVES, LIST, SPLIT FILE OFF,<br />

and REGRESSION. The command sequence using the macro facility is identical to the<br />

command sequence in which the specified commands are explicitly stated three separate<br />

times.<br />

* Macro with an argument.<br />

DEFINE myfreq (vars = !CHAREND(’/’))<br />

frequencies variables = !vars<br />

/format = notable<br />

/statistics = default skewness kurtosis.<br />

!ENDDEFINE.<br />

myfreq vars = AGE SEX EDUC RELIGION /.<br />

• The macro definition defines vars as the macro argument. In the macro call, four variables<br />

are specified as the argument to the macro myfreq. When the program expands the myfreq<br />

macro, it substitutes the argument, AGE, SEX, EDUC, and RELIGION, for !vars and<br />

executes the resulting commands.<br />

Macro Arguments<br />

The macro definition can include macro arguments, which can be assigned specific values in<br />

the macro call. There are two types of arguments: keyword and positional. Keyword arguments<br />

are assigned names in the macro definition; in the macro call, they are identified by name.<br />

Positional arguments are defined after the keyword !POSITIONAL in the macro definition; in<br />

the macro call, they are identified by their relative position within the macro definition.<br />

• There is no limit to the number of arguments that can be specified in a macro.<br />

• All arguments are specified in parentheses and must be separated by slashes.<br />

• If both keyword and positional arguments are defined in the same definition, the positional<br />

arguments must be defined, used in the macro body, and invoked in the macro call<br />

before the keyword arguments.<br />

Example<br />

* A keyword argument.<br />

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

frequencies variables = !arg1.<br />

!ENDDEFINE.<br />

macname arg1 = V1.<br />

• The macro definition defines macname as the macro name and arg1 as the argument. The<br />

argument arg1 has one token and can be assigned any value in the macro call.

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

Saved successfully!

Ooh no, something went wrong!