I am trying to create new variables based on the value of a macro variable created in the same data step. But I can't get this working. Can anyone help with this please?
The output I want to see is creation of new variables Month1-Month10 while reading in the first observation (&z=1). When reading the second observation, variables Month2-Month10 are populated (&z=2).
data test;
v=1; w=0.5; output;
v=2; w=0.7; output;
run;
%symdel z;
data test2;
set test;
call symput('z',compress(put(v,8.)));
%macro test;
%do t=&z %to 10;
month&t = 2*w;
%end;
%mend;
%test;
run;
%put &z; WARNING: Apparent symbolic reference Z not resolved. ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &z ERROR: The %FROM value of the %DO T loop is invalid. ERROR: The macro TEST will stop executing.
... View more