DATA Step, Macro, Functions and more

macro, go back to loop

Reply
Frequent Contributor
Frequent Contributor
Posts: 82

macro, go back to loop

 

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 .....;

run;

 

..........

 

 

%end;

 

%mend; 

PROC Star
Posts: 2,226

Re: macro, go back to loop

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;

 

Ask a Question
Discussion stats
  • 1 reply
  • 87 views
  • 1 like
  • 2 in conversation