Hello,
I am trying to run a loop in a Macro program.
I would like to go back to the loop if there is no observation in test2 . Is there any way for that ? Thank you very much.
%macro test ;
data test1;
set test;
where ;
run;
%do i= 1 %to 41;
data test2;
set test1;
where .....;
..........
%end;
%mend;
Here is one way. Does it suit you?
%do i= 1 %to 41; proc sql; create table test2 as select * from test1 where .....; run; %if &sqlobs=0 %then %goto next_iteration; .......... %next_iteration: %end;
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!
Submit your idea!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for:
View all other training opportunities.