Search code examples
sassas-macro

SAS Macro Language


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

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