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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.