I am running a macro loop that contains macro functions like so:
%macro loop;
%do j=1 %to 1000;
%macro variable;
%end;
%mend;
The macro variable itself has some macro functions enclosed like so:
%macro variable;
%macro rename(x);
proc sql;
create table Renamed&j&x as
select *,
rename1 as rename1,
rename2 as rename2,
...
from rename&j&x
quit;
%rename(1);
%rename(2);
....
%mend;
%mend;
What is the correct syntax for these sticky, nested macro loops and variables? I seem to remember using &&j and &x but I'm getting errors.
The code works if i replace all &j with a 2, so the code is fine, the recursive nature of the loop isn't injecting the variable correctly. TIA.
%macro x(n); %if %sysfunc(mod(&n,500)) = 0 %then %put NOTE: &=n; %x(%eval(&n+1)) %mend; %x(1)
It will go until you run out of memory. – Richard