I have the following code:
%macro MSA (Data=, Code=, MSAName=);
data &Data;
set NoDup;
%if MSA = &Code %then %do;
MSA_name = "&MSAName";
output &data;
%end;
run;
%mend MSA;
%MSA (Data=Bakersfield, Code=12540, MSAName=Bakersfield);
%MSA (Data=Chico, Code=17020, MSAName=Chico);
So I get two datasets as I want with one names Bakersfield and another Chico. However, the MSA column does not display the correct value (i.e. a column of 12540 for Bakersfield and 17020 for Chico for MSA), nor do I get a variable named MSA_Name that gives me the correct values (Bakersfield for all of the MSA_Name column, and Chico). What am I doing wrong?
MSA = 12540;is false (the macro processor doesn't access the variables in your data set, it just compares text), so the following code is executed:data Bakersfield; set NoDup; run;. You are just copying your data set.