Hi - first post on the forum, relatively new SAS user.
I wrote a macro to generate a bunch of variable declarations:
%macro gen(varlist);
%local k;
%local curvar;
%do k = 1 %to 120;
%let curvar = %scan(&varlist, &k);
&curvar.12 = &curvar.03 - &curvar.02;
&curvar.13 = &curvar.04 - &curvar.02;
&curvar.14 = &curvar.05 - &curvar.02;
&curvar.34 = &curvar.05 - &curvar.04;
%end;
%mend gen;
where the varlist input was this long (120 variables) list of variables in a random (but important) order.
At first I tried to call this macro in a data step after the INPUT section with all the variable names, because in the original file all of these declarations were just typed out, one by one, and this is where they were. It kept giving me an "apparent symbolic reference not resolved..." error. Then I made a second data step where I effectively just set the new dataset to the old dataset, and I was able to call the macro fine.
Are there rules about calling macros immediately after the INPUT part of a data step? Why would this work in the second data step but not the first?
... View more