Conditional Processing (DEFINE-!ENDDEFINE command)
The !IF construct
specifies conditions for processing. The syntax is as follows:
!IF (expression) !THEN statements
[!ELSE statements]
!IFEND
-
!IF,!THEN, and!IFENDare all required.!ELSEis optional. - If the result of the expression is true, the statements
following
!THENare executed. If the result of the expression is false and!ELSEis specified, the statements following!ELSEare executed. Otherwise, the program continues. - Valid operators for the expressions include
!EQ,!NE,!GT,!LT,!GE,!LE,!OR,!NOT, and!AND, or =, ~= (¬=), >, <, >=, <=, |, ~ (¬), and&. - When a macro is expanded, conditional processing constructs are interpreted after arguments are substituted and functions are executed.
-
!IFstatements can be nested whenever necessary. Parentheses can be used to specify the order of evaluation. The default order is the same as for transformations:!NOThas precedence over!AND, which has precedence over!OR.
Example
DEFINE mymacro(type = !DEFAULT(1) !TOKENS(1))
!IF (!type = 1)!then
frequencies variables=varone.
!ELSE
descriptives variables=vartwo.
!IFEND
!ENDDEFINE.