Overview (DO IF command)
The DO IF—END
IF structure conditionally executes one or more transformations
on subsets of cases based on one or more logical expressions. The ELSE command can be used within the structure
to execute one or more transformations when the logical expression
on DO IF is not true. The ELSE IF command within the structure provides
further control.
The DO IF—END IF structure is best used for conditionally executing multiple transformation
commands, such as COMPUTE, RECODE, and COUNT. DO IF—END IF transforms
data for subsets of cases defined by logical expressions. To perform
repeated transformations on the same case, use LOOP—END LOOP.
A DO IF—END IF structure can be used within an input program to define complex
files that cannot be handled by standard file definition facilities. See the topic Complex File Structures (DO IF command) for more information.
See END FILE for
information on using DO IF—END IF to instruct the program to stop reading data before it encounters
the end of the file or to signal the end of the file when creating
data.
Basic Specification
The basic
specification is DO IF followed
by a logical expression, a transformation command, and the END IF command, which has no specifications.