LENGTH Subcommand (REPEATING DATA command)
LENGTH
specifies
the length of each repeating data group. The default length is the number
of columns between the beginning column of the repeating data groups and the
ending position of the last variable specified on DATA
.
(For the first record of each input case, STARTS
specifies
the beginning column of the repeating groups. For continuation records, repeating
groups are read from column 1 by default or from the column specified on CONTINUED
.)
- The specification on
LENGTH
can be a number or the name of a variable. -
LENGTH
must be used if the last variable specified on theDATA
subcommand is not read from the last position of each repeating group, or if the length of the repeating groups varies across input cases. - If the length of the repeating groups varies across input
cases, the specification must be a variable whose value for each input case
is the length of the repeating groups for that case. The variable can be defined
on
DATA LIST
or created with transformation commands. - If the value of the variable specified on
LENGTH
is undefined or missing for an input case, the program displays a warning message and builds only one output case for that input case.
Example
* Read only the variable MAKE for each vehicle.
* The data contain two values that are not specified on the
DATA subcommand. The first is in position 9 of the repeating
groups, and the second is in position 10.
INPUT PROGRAM.
DATA LIST FILE=VEHICLE / SEQNUM 2-4 NUMPERS 6-7 NUMVEH 9-10.
REPEATING DATA STARTS=12 /OCCURS=NUMVEH /LENGTH=10
/DATA=MAKE 1-8 (A).
END INPUT PROGRAM.
-
LENGTH
indicates that each repeating group is 10 columns long.LENGTH
is required because MAKE is not read from the last position of each repeating group. As illustrated in previous examples, each repeating group also includes variable MODEL (position 9) and NUMCYL (position 10). -
DATA
specifies that MAKE is in positions 1 through 8 of each repeating group. Positions 9 and 10 of each repeating group are skipped.