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.

450 DEFINE—!ENDDEFINE<br />

Example<br />

* Incorrect order for !CMDEND.<br />

DEFINE macname (!POSITIONAL !CMDEND<br />

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

frequencies variables = !1.<br />

correlations variables= !2.<br />

!ENDDEFINE.<br />

macname A B C D E.<br />

• When the macro is called, all five tokens, A, B, C, D, and E, are assigned to the first positional<br />

argument. No variables are included on the variable list for CORRELATIONS,<br />

causing the program to generate an error message. The previous example declares the<br />

arguments in the correct order.<br />

Example<br />

* Using !CMDEND.<br />

SUBTITLE ’CHANGING DEFAULTS ON A COMMAND’.<br />

DEFINE myfreq (!POSITIONAL !CMDEND )<br />

frequencies !1<br />

/statistics=default skewness /* Modify default statistics.<br />

!ENDDEFINE.<br />

myfreq VARIABLES = A B /HIST.<br />

• The macro myfreq contains options for the FREQUENCIES command. When the macro is<br />

called, myfreq is expanded to perform a FREQUENCIES analysis on the variables A and B.<br />

The analysis produces default statistics and the skewness statistic, plus a histogram, as<br />

requested on the macro call.<br />

Example<br />

* Keyword arguments: Using a combination of token keywords.<br />

DATA LIST FREE / A B C D E.<br />

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

/arg2 = !ENCLOSE (’(’,’)’)<br />

/arg3 = !CHAREND(’%’))<br />

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

!ENDDEFINE.<br />

macdef arg1 = A arg2=(B C) arg3=D E %.<br />

• Because arg1 is defined with the !TOKENS keyword, the value for arg1 is simply specified<br />

as A. The value for arg2 is specified in parentheses, as indicated by !ENCLOSE. The value<br />

for arg3 is followed by a percent sign, as indicated by !CHAREND.<br />

Defining Defaults<br />

The optional !DEFAULT keyword in the macro definition establishes default settings for<br />

arguments.

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

Saved successfully!

Ooh no, something went wrong!