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.

Example<br />

DEFINE sesvars ()<br />

age sex educ religion.<br />

!ENDDEFINE.<br />

Overview<br />

Options<br />

DEFINE—!ENDDEFINE 441<br />

DEFINE—!ENDDEFINE defines a program macro, which can then be used within a command<br />

sequence. A macro can be useful in several different contexts. For example, it can be used to:<br />

• Issue a series of the same or similar commands repeatedly, using looping constructs rather<br />

than redundant specifications.<br />

• Specify a set of variables.<br />

• Produce output from several program procedures with a single command.<br />

• Create complex input programs, procedure specifications, or whole sessions that can then<br />

be executed.<br />

A macro is defined by specifying any part of a valid command and giving it a macro name.<br />

This name is then specified in a macro call within a command sequence. When the program<br />

encounters the macro name, it expands the macro.<br />

In the examples of macro definition throughout this reference, the macro name, body, and<br />

arguments are shown in lower case for readability. Macro keywords, which are always preceded<br />

by an exclamation point (!), are shown in upper case. For additional examples of the<br />

macro facility, see Appendix D.<br />

Macro Arguments. You can declare and use arguments in the macro definition and then assign<br />

specific values to these arguments in the macro call. You can define defaults for the arguments<br />

and indicate whether an argument should be expanded when the macro is called. (See<br />

pp. 444–451.)<br />

Macro Directives. You can turn macro expansion on and off (see p. 451).<br />

String Manipulation Functions. You can process one or more character strings and produce<br />

either a new character string or a character representation of a numeric result (see pp.<br />

451–453).<br />

Conditional Processing. You can build conditional and looping constructs (see p. 455).<br />

Macro Variables. You can directly assign values to macro variables (see p. 458).<br />

Basic Specification<br />

All macros must start with the DEFINE command and end with the macro command<br />

!ENDDEFINE. These commands identify the beginning and end of a macro definition and are<br />

used to separate the macro definition from the rest of the command sequence.

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

Saved successfully!

Ooh no, something went wrong!