Thanks @Patrick for inspiring me.
When using DOW-Loop, I used to not writing a "stop" statement, but today I see difference from this post:Why read data 1 times or 2 times when declare hash object with or with... - SAS Support Communities
DOW-Loop with "put _n_=" above:
data _null_;
put _n_=;
do until(_eof_);
set sashelp.class end=_eof_;
end;
run;
SAS Log:
_N_=1 _N_=2
DOW-Loop with "put _n_=" above and "stop" behind:
data _null_;
put _n_=;
do until(_eof_);
set sashelp.class end=_eof_;
end;
stop;
run;
SAS Log:
_N_=1
DOW-Loop with "put _n_=" behind:
data _null_;
do until(_eof_);
set sashelp.class end=_eof_;
end;
put _n_=;
run;
SAS Log:
_N_=1
I have read The SAS Supervisor - SAS Support Communities and still not figure it out.
DO UNTIL forces at least one iteration.
So your step does this:
In the first iteration of the DATA step (_N_ = 1), it works through the dataset until the last observation is read and _eof_ is set.
Then it goes to the next DATA step iteration (_N_ = 2), performs the first iteration of the DO where the SET statement tries to read past the last observation, so the DATA step is terminated immediately.
I highly recommend reading:
https://analytics.ncsu.edu/sesug/2002/TU05.pdf
and
https://support.sas.com/resources/papers/proceedings09/038-2009.pdf
Bart
For further clarification: the END= variable is set when the last observation is read, but the termination of the DATA step happens when a read past the last observation is attempted.
Data steps that have input stop when a statement tries to read past its input.
In these examples that is the SET statement.
But the same thing applies to data steps that use an INPUT statements to read in data.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.