Question

On SAS, after defining Macro Language, for example,

   %macro source(x);
   ......
   %mend source;

I want to substitute x for 17 to 63, does there have an easy way to do this instead of key in

%source(16);
%source(17);
...
%source(63);
Was it helpful?

Solution

You could create a new macro with a do-statement to run you macro a select number of times:

%MACRO RunMacro(from, to);
    %DO i = &from. %TO &to.;
        %source(&i.);
    %END;
%MEND RunMacro;

%RunMacro(16, 63);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top