Hi,
I am pretty new to macro and need some help here. Below is my dataset:
data mydata;
input var1 var1_suffix var2 var2_suffix var3 var3_suffix var4 var4_suffix var5 var5_suffix;
datalines;
4.2 1 1.8 0 2.3 0 3.5 0 2.3 1
3 0 2.5 0 5.2 1 6.4 0 2.4 0
;
run;
var1 through var5 are five variables of interest. var1_suffix through var5_suffix are corresponding indicators which take values of 0 or 1. If its value=1, then I want set the corresponding variable value to missing. For example, var1=4.2 and var1_suffix=1 so I will change the value of var1 to missing, the result should be var1=. and var1_suffix=1. I wrote a macro to do this:
%MACRO mymacro(varLIST);
DATA mydataout;
SET mydata;
%LET K=1;
%LET a=%SCAN(&varLIST,&K);
%DO %WHILE("a" NE "");
%IF &a_suffix=1 %THEN &a=.;
%LET K=%EVAL(&K+1);
%LET a=%SCAN(&varLIST,&K);
%END;
RUN;
%MEND;
%mymacro(var1 var2 var3 var4 var5);
However, SAS gave an error message "Apparent symbolic reference A_SUFFIX not resolve". I guess I shouldn't use &a_suffix to stand for the variables of var1_suffix to var5_suffix, but I don't know how to fix it. Any input will be appreciated.
Lu