Overview (END CASE command)
END CASE
is used
in an INPUT PROGRAM—END INPUT PROGRAM
structure
to signal that a case is complete. Control then passes to the commands immediately
following the input program. After these commands are executed for the newly
created case, the program returns to the input program and continues building
cases by processing the commands immediately after the last END
CASE
command that was executed. For more information about the
flow control in an input program, see INPUT PROGRAM—END
INPUT PROGRAM
.
END CASE
is especially
useful for restructuring files, either building a single case from several
cases or building several cases from a single case. It can also be used to
generate data without any data input (see DO REPEAT
for
an example).
Basic Specification
The basic specification is simply END
CASE
. There are no additional specifications.
Syntax Rules
-
END CASE
is available only within an input program and is generally specified within a loop. - Multiple
END CASE
commands can be used within an input program. Each builds a case from the transformation and data definition commands executed since the lastEND CASE
command. - If no
END CASE
is explicitly specified, anEND CASE
command is implied immediately beforeEND INPUT PROGRAM
and the input program loops until an end-of-file is encountered or specified (seeEND FILE
).
Operations
- When an
END CASE
command is encountered, the program suspends execution of the rest of the commands before theEND INPUT PROGRAM
command and passes control to the commands after the input program. After these commands are executed for the new case, control returns to the input program. The program continues building cases by processing the commands immediately after the most recentEND CASE
command. Use a loop to build cases from the same set of transformation and data definition commands. - When multiple
END CASE
commands are specified, the program follows the flow of the input program and builds a case whenever it encounters anEND CASE
command, using the set of commands executed since the lastEND CASE
. - Unless
LEAVE
is specified, all variables are reinitialized each time the input program is resumed. - When transformations such as
COMPUTE
, definitions such asVARIABLE LABELS
, and utilities such asPRINT
are specified between the lastEND CASE
command andEND INPUT PROGRAM
, they are executed while a case is being initialized, not when it is complete. This may produce undesirable results.