Creating datasets within Macro SAS -


i have 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 2 datasets want 1 names bakersfield , chico. however, msa column not display correct value (i.e. column of 12540 bakersfield , 17020 chico msa), nor variable named msa_name gives me correct values (bakersfield of msa_name column, , chico). doing wrong?

the issues have code mingle macro syntax data step. please try following:

%macro msa (data=, code=, msaname=);     data &data;     set nodup;         if msa = &code /*if msa char, need quote "&code"*/  do;         msa_name = "&msaname"; output; end;       run;     %mend msa;    %msa (data=bakersfield, code=12540, msaname=bakersfield);    %msa (data=chico,       code=17020, msaname=chico); 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -