DO IF marks
the beginning of the control structure and END IF marks the end. Control for a case is passed out
of the structure as soon as a logical condition is met on a DO IF, ELSE IF, or ELSE command.
A logical expression is evaluated as true, false,
or missing. A transformation specified for a logical expression is
executed only if the expression is true.
Logical expressions are evaluated in the following
order: functions, exponentiation, arithmetic operations, relations,
and finally, logical operators. (For strings, the order is functions,
relations, and then logical operators.) When more than one logical
operator is used, NOT is evaluated
first, followed by AND, and then OR. You can change the order of operations
using parentheses.
Numeric variables created within a DO IF structure are initially set to the
system-missing value. By default, they are assigned an F8.2 format.
New string variables created within a DO IF structure are initially set to a blank
value and are assigned the format specified on the STRING command that creates them.
If the transformed value of a string variable exceeds
the variable’s defined format, the value is truncated. If the
value is shorter than the format, the value is right-padded with blanks.
If WEIGHT is
specified within a DO IF structure,
it takes effect unconditionally.
Commands that take effect immediately without reading
the data or executing pending commands (e.g., VALUE LABELS, MISSING VALUES, VARIABLE LABEL), commands
that don't require an active dataset (e.g., DISPLAY, HOST, INSERT, OMS, SET) and the GET command are processed unconditionally
and immediately each time they are encountered in a DO IF structure. The specified condition
is ignored for these commands.
Commands that require a data pass, such as statistical
or charting procedures, cannot be included in a DO IF structure and will cause the command to fail.
The DO IF—END IF structure (like LOOP—END LOOP) can include commands such as DATA LIST, END CASE, END FILE, and REREAD, which define complex file structures.