How " 'just' 'leave' " not leave a DOW loop but "outputs"?
data have;
do i=1 to 5;
do _n_=1 to 8;
output;
end;
end;
run;
data dow;
do until(last.i);
set have;
by i;
leave; /* behaves as explicit output, why?*/
end;
run;
data dow;
do until(last.i);
set have;
by i;
*leave; /* when commented, zips through in one shot to the last.i as known*/
end;
run;
If you leave the DO loop every time then the DO loop is doing nothing. So it works the same as if you coded.
data dow;
set have;
by i;
run;
So if you know why the simple data step above results in DOW having the same number of observations as HAVE then you can answer your own question.
I read this several times and I am still not sure what you are asking.
Observations:
I would never (or almost never) put a SET statement within a loop without POINT=.
DATA steps have an implicit OUTPUT unless there is an explicit OUTPUT somewhere.
If you just want to process the last observation in each BY group skip the loop and use.
if last.i then output; /* or do or whatever you want to have happen. */
If you leave the DO loop every time then the DO loop is doing nothing. So it works the same as if you coded.
data dow;
set have;
by i;
run;
So if you know why the simple data step above results in DOW having the same number of observations as HAVE then you can answer your own question.
Thank you Tom, Nice one indeed!
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.