DATA Step, Macro, Functions and more

Data step flow

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Data step flow

 

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;


Accepted Solutions
Solution
‎09-28-2016 10:12 AM
Super User
Posts: 10,500

Re: Data step flow

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.

View solution in original post


All Replies
Solution
‎09-28-2016 10:12 AM
Super User
Posts: 10,500

Re: Data step flow

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.

Occasional Contributor
Posts: 9

Re: Data step flow

You are right, I have noticed it yet. Thanks very much! Smiley LOL

Respected Advisor
Posts: 4,646

Re: Data step flow

@shengnian, please mark @ballardw's answer as Accepted.

PG
Occasional Contributor
Posts: 9

Re: Data step flow

Thanks for your remainding!Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 264 views
  • 2 likes
  • 3 in conversation