First, the loop has 8 levels and the total calls will be roughly 100**8/2 which is a huge number. It almost is impossible to make your problem doable. You need to reconsider/formulate your problem. It is good tip of always to aviod to have nested loops!
Second, it is possible to control the loop levels based on a pre-defined parameter.
In general, you cannot control the level within a data step. This is simple because SAS data step is a compiling language. You cannot hide the loop levels from the SAS compiler. But you can use SAS macro language to generate the loop levels as desired, the desired codes then pass to SAS compiler and executed.
Similarly, you cannot control macro loop levels with SAS macros. Pretty Sad!
Here is a old way you can bypass it(generate SAS macro language with a data step). The same logic can be applied to generate data step codes. The old trick always works!
n=levels
stop=100 in your problem.
Do not try it with large number of n and stop. Here will take long to to even to compile it and take forever to run it.
data _null_;
file 'c:\temp\testmacro.sas';
length loopvar loopstart loopend $30;
n=3;
stop=6;
***********************;
put '%macro circle(dummy);';
do loop=1 to n;
loopvar=catt('_i_',loop);
if loop=1 then loopstart='1';
else loopstart=catt('&_i_',loop-1,'+1');
loopend=stop-n+loop;
put '%do ' loopvar '=%eval(' loopstart ') %to ' loopend ';';
end;
/* put '*%woe;';*/
put 'proc print data=sashelp.class(obs=1);run;';
do loop=1 to n;
put '%end; ' ;
end;
put '%mend circle;';
run;
options source2 mprint;
%include 'c:\temp\testmacro.sas';
%circle(dummy)
;;;;;