Overview (REPEATING DATA command)
REPEATING DATA
reads
input cases whose records contain repeating groups of data. For each repeating
group, REPEATING DATA
builds one output
case in the active dataset. All of the repeating groups in the data must contain
the same type of information, although the number of groups for each input
case may vary. Information common to the repeating groups for each input case
can be recorded once for that case and then spread to each resulting output
case. In this respect, a file with a repeating data structure is like a hierarchical
file with both levels of information recorded on a single record rather than
on separate record types. For information on reading hierarchical files, see FILE TYPE—END FILE TYPE
.
REPEATING DATA
must be
used within an INPUT PROGRAM
structure
or within a FILE TYPE
structure with
mixed or nested data. In an INPUT PROGRAM
structure, REPEATING DATA
must be preceded by a DATA LIST
command. In a FILE
TYPE
structure, DATA LIST
is
needed only if there are variables to be spread to each resulting output case.
Options
Length of Repeating Groups. If
the length of the repeating groups varies across input cases, you can specify
a variable that indicates the length on the LENGTH
subcommand.
You can also use LENGTH
if you do not
want to read all the data in each repeating group.
Continuation Records. You can use the CONTINUED
subcommand to indicate that the repeating
groups for each input case are contained on more than one record. You can
check the value of an identification variable across records for the same
input case using the ID
subcommand.
Summary Tables. You
can suppress the display of the table that summarizes the names, locations,
and formats of the variables specified on the DATA
subcommand
using the NOTABLE
subcommand.
Basic Specification
The basic specification requires three subcommands: STARTS
, OCCURS
,
and DATA
.
-
STARTS
specifies the beginning column of the repeating data segments. When there are continuation records,STARTS
can specify the ending column of the last repeating group on the first record of each input case. -
OCCURS
specifies the number of repeating groups on each input case.OCCURS
can specify a number if the number of repeating groups is the same for all input cases. Otherwise,OCCURS
should specify the name of a variable whose value for each input case indicates the number of repeating groups for that case. -
DATA
specifies names, location within the repeating segment, and format for each variable to be read from the repeated groups.
Subcommand Order
-
DATA
must be the last subcommand specified onREPEATING DATA
. - The remaining subcommands can be named in any order.
Syntax Rules
-
REPEATING DATA
can be specified only within anINPUT PROGRAM
structure, or within aFILE TYPE
structure with mixed or nested data.DATA LIST
,REPEATING DATA
, and any transformation commands used to build the output cases must be placed within theINPUT PROGRAM
orFILE TYPE
structure. Transformations that apply to the output cases should be specified after theEND INPUT PROGRAM
orEND FILE TYPE
command. -
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. -
CONTINUED
must be used if repeating groups for each input case are continued on successive records. - The
DATA LIST
command used withREPEATING DATA
must define all fixed-format data for the records. - Repeating groups are usually recorded at the end of the fixed-format records, but fixed-format data may follow the repeating data in data structures such as IBM SMF and RMF records. Use the following sequence in such cases.
DATA LIST .../* Read the fixed-format data before repeating data
REREAD COLUMNS= .../* Skip repeating data
DATA LIST .../* Read the fixed-format data after repeating data
REPEATING DATA ... /*Read repeating data