1

Currently, my macro is running to insert a constant number of rows:

%MACRO ADD_PERIOD;

%DO P = 1 %TO 39;

Would I be able to modify this macro or create a new macro to run this, not 39 times, but replace the number of loops with a variable I have from another table?

Thank you!

Young
  • 11
  • 3

1 Answers1

2

Use the call symput to turn that variable(my_var) into a macro variable(loop_var)

data _null_;
set your_table;
call symput("loop_var", my_var);
run;

and use & to resolve the macro variable into your code

%MACRO ADD_PERIOD;

%DO P = 1 %TO &loop_var;

You could also pass that macro variable as parameters into your macro.

 %MACRO ADD_PERIOD(loop_var);
in_user
  • 1,948
  • 1
  • 15
  • 22