BookmarkSubscribeRSS Feed
schoi
Calcite | Level 5

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

3 REPLIES 3
Astounding
PROC Star

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.

Tom
Super User Tom
Super User

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;

 

schoi
Calcite | Level 5

Thanks everyone.  It actually works.  There was something wrong with my logic in my code that made me think it wasn't working.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 683 views
  • 0 likes
  • 3 in conversation