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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.