STARTS Subcommand (REPEATING DATA command)
STARTS
indicates
the beginning location of the repeating data segment on the first record of
each input case. STARTS
is required and
can specify either a number or a variable name.
- If the repeating groups on the first record of each input
case begin in the same column,
STARTS
specifies a column number. - If the repeating groups on the first record of each input
case do not begin in the same column,
STARTS
specifies the name of a variable whose value for each input case indicates the beginning location of the repeating groups on the first record. The variable can be defined onDATA LIST
or created by transformation commands that precedeREPEATING DATA
. - When repeating groups are continued on multiple records for
each input case,
STARTS
must also specify an ending location if there is room on the logical record length for more repeating groups than are contained on the first record of each input case. The ending column applies only to the first record of each input case. See theCONTINUED
subcommand for an example. - The ending column can be specified as a number or a variable name. Specifications for the beginning column and the ending column are separated by a hyphen. The values of the variable used to define the ending column must be valid values and must be larger than the starting value.
- If the variable specified for the ending column is undefined
or missing for an input case, the program displays a warning message and builds
no output cases from that input case. If the variable specified for the ending
column on
STARTS
has a value that is less than the value specified for the starting column, the program issues a warning and builds output cases only from the continuation records of that input case; it does not build cases from the first record of the case. - If the ending location is required but not supplied, the
program generates output cases with system-missing values for the variables
specified on the
DATA
subcommand and may misread all data after the first or second record in the data file (see theCONTINUED
subcommand).
Repeating Groups in the Same Location
INPUT PROGRAM.
DATA LIST FILE=VEHICLE / SEQNUM 2-4 NUMPERS 6-7 NUMVEH 9-10.
REPEATING DATA STARTS=12 /OCCURS=NUMVEH
/DATA=MAKE 1-8 (A) MODEL 9 (A) NUMCYL 10.
END INPUT PROGRAM.
-
STARTS
specifies column number 12. The repeating groups must therefore start in column 12 of the first record of each input case.
Repeating Groups in Varying Locations
INPUT PROGRAM.
DATA LIST FILE=VEHICLE / SEQNUM 2-4 NUMPERS 6-7 NUMVEH 9-10.
+ DO IF (SEQNUM LE 100).
+ COMPUTE FIRST=12.
+ ELSE.
+ COMPUTE FIRST=15.
+ END IF.
REPEATING DATA STARTS=FIRST /OCCURS=NUMVEH
/DATA=MAKE 1-8 (A) MODEL 9 (A) NUMCYL 10.
END INPUT PROGRAM.
- This example assumes that each input case is recorded on a single record and that there are no continuation records. Repeating groups begin in column 12 for all records with sequence numbers 1 through 100 and in column 15 for all records with sequence numbers greater than 100.
- The sequence number for each record is defined as variable SEQNUM on the
DATA LIST
command. TheDO IF—END IF
structure creates the variable FIRST with value 12 for records with sequence numbers through 100 and value 15 for records with sequence numbers greater than 100. - Variable FIRST is specified
on the
STARTS
subcommand.