Please post an actual example. Why would you have a macro variable which indirectly points the data to append? I mean you could do:
%macro appnd (); data want; set a %if "&city."="blr" %then %do; b; %end; %else %do; c; %end; run; %mend appnd; %appnd;
But you could vastly simplfy it just by having the macro variable point to the actual table you want to append:
%let city=b; data want; set a &city.; run;
I suppose the key question here is why your doing this at all. The data should have all the information needed, i.e. a variable in there for filtering. So you would simply do:
data want; set a b c; where city="blr"; run;
I think your just complicating the whole thing.
Maybe:
data want; set %sysfunc(coalescec(&var.,C)); run;
This will set the first if non-missing, otherwise c. I still don't see any value in this approach however. macro is not for data processing, put data in the dataset, then use where filtering its quicker, uses less resources, and is simpler coding.
Cool, please remember to mark appropriate posts as the answer when you have what you need.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.