Parameterizing IBM SPSS Statistics Steps
Syntax files can be parameterized to allow the values for job variables to be used within the syntax during execution. A parameter referencing a job variable has the following structure in the syntax file:
@varname
where varname corresponds to the name of a job variable defined for the job initiating execution of the IBM® SPSS® Statistics step. The variable name is subject to the following restrictions:
- The name must be 64 characters or less
- The first character after the @ symbol must be a letter
- The name can contain both letters and numbers, but no special characters are allowed
- The name cannot contain spaces or carriage returns
The syntax file for a job step may include any number of parameters, but there must be a job variable defined for each parameter in the file. Parameters may be used to insert any text into the syntax, including additional syntax, values, variable names, and case numbers. When the job initiates processing of the syntax file, the parameters are replaced with values associated with that job execution. The parameters may simply use the defined default values, or have values defined by specific schedules.
For example, the following syntax generates frequency tables for the fields race and region.
FREQUENCIES VARIABLES=race region
/ORDER=ANALYSIS.
The field names can be replaced with parameters, such as:
FREQUENCIES VARIABLES=@var1 @var2
/ORDER=ANALYSIS.
If the job containing this syntax as a job step has variables named var1 and var2, the values for those variables will be used during execution. The values may be race and region for one execution, but age and educ for another. Alternatively, the entire field list may be replaced by the single parameter @varlist, provided that the value defined for the job variable varlist is a space delimited list of field names.