You can see that the DATA step works
like a loop, repetitively executing statements to read data values
and create observations one by one. At the beginning of the second
iteration, the value of _N_ is 2, and _ERROR_ is still 0. Each loop
(or cycle of execution) is called an iteration.
As the INPUT statement executes
for the second time, the values from the second record are read into
the input buffer and then into the program data vector.
Next, the value for Total
is calculated based on the current values for InStock and BackOrd.
The RUN statement indicates the end of the DATA step loop.
data work.update;
infile invent;
input Item $ 1-13 IDnum $ 15-19
InStock 21-22 BackOrd 24-25;
Total=instock+backord;
run;
At the bottom of the DATA
step, the values in the program data vector are written to the data
set as the second observation.
data work.update;
infile invent;
input Item $ 1-13 IDnum $ 15-19
InStock 21-22 BackOrd 24-25;
Total=instock+backord;
run;
Next, the value of _N_
increments from 2 to 3, control returns to the top of the DATA step,
and the values for Item, IDnum, InStock, BackOrd, and Total are reset
to missing.
data work.update;
infile invent;
input Item $ 1-13 IDnum $ 15-19
InStock 21-22 BackOrd 24-25;
Total=instock+backord;
run;