The DEFINE command creates a macro, which is a name for a fragment of PSPP syntax called the macro’s body. Following the DEFINE command, syntax may call the macro by name any number of times. Each call substitutes, or expands, the macro’s body in place of the call, as if the body had been written in its place.
The following syntax defines a macro named
!vars that expands
to the variable names
v1 v2 v3. The macro’s name begins with
‘!’, which is optional for macro names. The
the macro name are required:
DEFINE !vars() v1 v2 v3 !ENDDEFINE.
Here are two ways that
!vars might be called given the
DESCRIPTIVES !vars. FREQUENCIES /VARIABLES=!vars.
With macro expansion, the above calls are equivalent to the following:
DESCRIPTIVES v1 v2 v3. FREQUENCIES /VARIABLES=v1 v2 v3.
!vars macro expands to a fixed body. Macros may have more
!IFconstructs, for conditional expansion. See Macro Conditional Expansion.
!DOconstruct, for looping over a numerical range or a collection of tokens. See Macro Loops.
!LETconstructs, for assigning to macro variables. See Macro Variable Assignment.
Many identifiers associated with macros begin with ‘!’, a character not normally allowed in identifiers. These identifiers are reserved only for use with macros, which helps keep them from being confused with other kinds of identifiers.
The following sections provide more details on macro syntax and semantics.