Hello,
Suppose I have the following small piece of code:
data row1col1;
a = 12;
output;
run;
data _null_;
put nobs=;
*stop;
set row1col1 nobs=nobs;
run;
Notice that the stop statement in the data _null_ step has been commented out. Then the code puts nobs to the log twice, but I don't understand why it doesn't just put it once, nor why it puts a non-zero value, since the "put" statement is above the "set" statement.
If I include the stop statement, it puts nobs just once.
There are numerous paper talking about this, briefly speaking, data step will loop a 'half' loop until reach 'set' statement after the end of the data set has been reached. Considering the following scenarios:
data row1col1;
a = 12;
output;
run;
/*1. 0 obs: just a half loop*/
data empty;
set row1col1(obs=0);
run;
data _null_;
put nobs=;
*stop;
set empty nobs=nobs;
run;
/*2. with 'put' after 'set': one and half loop while not reaching 'put'*/
data _null_;
set row1col1 nobs=nobs;
put nobs=;
run;
Of course, with 'stop', it stops in the middle the loop before even one loop can be finished.
HTH,
Haikuo
Update: here is a paper by the famous Ian whitlock: http://www2.sas.com/proceedings/sugi22/ADVTUTOR/PAPER34.PDF
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.