I don't know why you would not use &W as the parameter in your macro call, since its value is unchanged for your entire data step. But you may be looking for the RESOLVE function, which provides a means to delay resolution of a macro call until data step execution - i..e it's a means of having the data in a given record influence what the macro returns. As in: %macro t(arg); %if &arg=2 %then 2; %else 3; %mend t; data have; do a=1 to 2;output; end; run; data _null_; set have; b=a*resolve(cats('%t(',a,')')); put a= b=; run; But this will probably generate a significant performance hit, which you can test by multiplying data set HAVE to, say 100,000 observations. Then run the above data _null_ step (take out the put statement), and compare its speed to this data _null_ step: data _null_; set have; if a=1 then b=a*%t(1); else b=a*%t(2); run;
... View more