HTH
Patrick
%macro IterOverDs(IterDS=,OneTimeDs=);
%if not %SYMGLOBL(LastIterObs) %then
%do;
%global LastIterObs;
%let LastIterObs=0;
%end;
%global newds;
%let newds=new_&OneTimeDs;
data new_&OneTimeDs;
set &OneTimeDs end=last;
if _n_=1 then
CurrentIterObs=&LastIterObs+1;
else
if mod(CurrentIterObs,NIterObs)=0 then
do;
CurrentIterObs=1;
end;
else
CurrentIterObs+1;
recno=CurrentIterObs;
set &IterDS nobs=NIterObs point=CurrentIterObs;
if last then
do;
if CurrentIterObs=NIterObs then call symput('LastIterObs','0');
else call symput('LastIterObs',cats(CurrentIterObs));
end;
run;
%mend;
%let LastIterObs=0;
data iter;
do iter_var=0 to 90 by 10;
output;
end;
run;
data a1;
do var_a1=0 to -15 by-1;
output;
end;
run;
%IterOverDs(IterDS=iter,OneTimeDs=a1);
title "DS is &newds";
proc print data=&newds;
run;
data a2;
do var_a1=1 to 7;
output;
end;
run;
%IterOverDs(IterDS=iter,OneTimeDs=a2);
title "DS is &newds";
proc print data=&newds;
run;
/* and so on and so on */