I am learning SAS data setp flow recently, and I found a interesting question. Please see the following programs. The only difference between data bb and data cc is that " put _all_" was a comment statement in data bb, which was not in data cc.
However, it made a big difference to the result. I could underatand the number of dataset bb is zero, but I wonder what happened to dataset cc. Can someone explain it? Thanks!
data aa;
do A = 1 to 20;
output;
B = A;
end;
run;
data bb;
do until (i >= 5);
set aa;
/* put _all_*/
i = _N_;
i + 1;
end;
run;
data cc;
do until (i >= 5);
set aa;
put _all_
i = _N_;
i + 1;
end;
run;
If the code you ran is exactly as posted you get a difference because the Put _all_ does not have a ; at the end and the next line i=_n_ is considered part of the PUT instruction.
If the code you ran is exactly as posted you get a difference because the Put _all_ does not have a ; at the end and the next line i=_n_ is considered part of the PUT instruction.
You are right, I have noticed it yet. Thanks very much! ![]()
@shengnian, please mark @ballardw's answer as Accepted.
Thanks for your remainding!![]()
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.