Hi,
Execute this data step, which sheds some light of the execution:
data xyz;
do i = 1 to 3;
putlog 'BEFORE' _ALL_;
set abc;
X + 1;
output;
putlog 'AFTER ' _ALL_;
end;
run;
First the inner loop is executed 3 times, and 3 rows from abc dataset are read into the PDV, and than output. This is only the first data step cycle (_N_=1). (Remember: data step always constructs a loop if you use a set,merge,infile,update,modify statement.)
Then comes the second cycle of the data step (_N_=2).
The inner loop starts 2 times: First it is executed completely, but in the second iteration there comes the set statement. And this is the moment, when the data step finishes (exits, stops), because there are no more observations in abc dataset.