DATA Step, Macro, Functions and more

How to use macro with multiple quotation marks in pass-through?

Reply
Occasional Contributor
Posts: 5

How to use macro with multiple quotation marks in pass-through?

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

Super User
Posts: 6,899

Re: How to use macro with multiple quotation marks in pass-through?

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.

Super User
Super User
Posts: 8,261

Re: How to use macro with multiple quotation marks in pass-through?

[ Edited ]

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;

 

Occasional Contributor
Posts: 5

Re: How to use macro with multiple quotation marks in pass-through?

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

Ask a Question
Discussion stats
  • 3 replies
  • 124 views
  • 0 likes
  • 3 in conversation