input file is a SAS data set, however, SAS does not create an input buffer. SAS writes
the input data directly to the PDV.)
The PDV contains all the variables in the input data set, the variables created in DATA
step statements, and the two variables, _N_ and _ERROR_, that are automatically
generated for every DATA step. The _N_ variable represents the number of times the
DATA step has iterated. The _ERROR_ variable acts like a binary switch whose value is
0 if no errors exist in the DATA step, or 1 if one or more errors exist. The following
figure shows the Input Buffer and the program data vector after DATA step compilation.
Figure 18.2 Input Buffer and Program Data Vector
Input Buffer
1 2 3 4 5 6 7 8 9
1
0 1 2 3 4 5 6 7 8 9
2
0
Program Data Vector
TeamName ParticipantName Event1 TeamTotal _N_ _ERROR_
Drop
Event2 Event3
1 0
Drop Drop
1 2 3 4 5
0
Variables that are created by the INPUT and the Sum statements (TeamName,
ParticipantName, Event1, Event2, Event3, and TeamTotal) are set to missing initially.
Note that in this representation, numeric variables are initialized with a period and
character variables are initialized with blanks. The automatic variable _N_ is set to 1; the
automatic variable _ERROR_ is set to 0.
The variable TeamName is marked Drop in the PDV because of the DROP= data set
option in the DATA statement. Dropped variables are not written to the SAS data set.
The _N_ and _ERROR_ variables are dropped because automatic variables created by
the DATA step are not written to a SAS data set. See Chapter 4, “SAS Variables,” on
page 37 for details about automatic variables.
Reading a Record
SAS reads the first data line into the input buffer. The input pointer, which SAS uses to
keep its place as it reads data from the input buffer, is positioned at the beginning of the
buffer, ready to read the data record. The following figure shows the position of the input
pointer in the input buffer before SAS reads the data.
Figure 18.3 Position of the Pointer in the Input Buffer Before SAS Reads Data
Input Buffer
1 2 3 4 5 6 7 8 9
1
0 1 2 3 4 5 6 7 8 9
2
0 1 2 3 4 5
K n i g h t s S u e 6 8 8
The INPUT statement then reads data values from the record in the input buffer and
writes them to the PDV where they become variable values. The following figure shows
both the position of the pointer in the input buffer, and the values in the PDV after SAS
reads the first record.
406 Chapter 18 • DATA Step Processing