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 CASEis available only within an input program and is generally specified within a loop. - Multiple
END CASEcommands can be used within an input program. Each builds a case from the transformation and data definition commands executed since the lastEND CASEcommand. - If no
END CASEis explicitly specified, anEND CASEcommand is implied immediately beforeEND INPUT PROGRAMand the input program loops until an end-of-file is encountered or specified (seeEND FILE).
Operations
- When an
END CASEcommand is encountered, the program suspends execution of the rest of the commands before theEND INPUT PROGRAMcommand 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 CASEcommand. Use a loop to build cases from the same set of transformation and data definition commands. - When multiple
END CASEcommands are specified, the program follows the flow of the input program and builds a case whenever it encounters anEND CASEcommand, using the set of commands executed since the lastEND CASE. - Unless
LEAVEis specified, all variables are reinitialized each time the input program is resumed. - When transformations such as
COMPUTE, definitions such asVARIABLE LABELS, and utilities such asPRINTare specified between the lastEND CASEcommand andEND INPUT PROGRAM, they are executed while a case is being initialized, not when it is complete. This may produce undesirable results.