Examples (DEFINE-!ENDDEFINE command)

Example

* Macro without arguments: Specify a group of variables.
 
DEFINE sesvars ()
   age sex educ religion
!ENDDEFINE.
 
FREQUENCIES VARIABLES=sesvars.

Example

* Macro without arguments: Repeat a sequence of commands.
 
DATA LIST FILE = MAC4D /GROUP 1   REACTIME 3-5 ACCURACY 7-9.
VALUE LABELS GROUP    1'normal'
                      2'learning disabled'.
* Macro definition.
DEFINE check ()
split file by group.
frequencies variables = reactime accuracy
  /histogram.
descriptives reactime accuracy.
list.
split file off.
regression variables = group reactime accuracy
  /dependent = accuracy
  /enter
  /scatterplot (reactime, accuracy).
!ENDDEFINE.

check.                       /* First call of defined macro check

COMPUTE REACTIME = SQRT (REACTIME).
COMPUTE ACCURACY = SQRT (ACCURACY).

check.                       /* Second call of defined macro check

COMPUTE REACTIME = lg10 (REACTIME * REACTIME).
COMPUTE ACCURACY = lg10 (ACCURACY * ACCURACY).

check.                       /* Third call of defined macro check

Example

* Macro with an argument.
 
DEFINE myfreq (vars = !CHAREND('/'))
frequencies variables = !vars
  /format = notable
  /statistics = default skewness kurtosis.
!ENDDEFINE.
 
myfreq vars = age sex educ religion /.