I have a macro with multiple quotation marks. For example,
%let animal = 'cow', 'pig', 'chicken'
I want to use the macro animal in the WHERE clause in a proc sql pass-through query. How do I do that?
I already tried bquote and str but it doesn't seem to work.
Thanks
You don't need any functions. Anywhere in the program where this would be valid syntax:
'cow', 'pig', 'chicken'
just insert &ANIMAL at that point.
Did you try it? What problem did you have?
%let animal = 'cow', 'pig', 'chicken' ;
proc sql ;
connect to oracle as mydb ..... ;
select * from connection to mydb
(select * from have
where animal in (&animal)
);
quit;
Thanks everyone. It actually works. There was something wrong with my logic in my code that made me think it wasn't working.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—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.