I am working inside a macro. Everything is running nicely and I am proud of myself for making this thing. Going to save me some time. I have one little thing.
I do an SQL statement and I select some stuff along with
'&myvariable._myfilename only' as location like
proc sql;
title 'differences';
select foo, '&myvariable._myfilename only' as location
from bar
etc
The &myvariable. won't resolve to the value inside the quoted SQL.
If when I ran the macro myvariable were ABC, I would want location to have the value 'ABC_myfilename only' in the output.
I've tried CATS and 'stuff'n and some other silly stuff.
I'm guessing it's a little piece of syntax I don't know and can't find.
Can you help?
Congrats, you should be proud of yourself! The macro language is hard.
The little bit of syntax you're missing is the fact that macro variables don't resolve inside of single quotes. If you change to double quotes, it should work fine.
proc sql;
title 'differences';
select foo, "&myvariable._myfilename only" as location
from bar
etc
Congrats, you should be proud of yourself! The macro language is hard.
The little bit of syntax you're missing is the fact that macro variables don't resolve inside of single quotes. If you change to double quotes, it should work fine.
proc sql;
title 'differences';
select foo, "&myvariable._myfilename only" as location
from bar
etc
@HB wrote:
Really SAS? Really? You're going to do that to me? Single vs double quotes. LOL.
Thanks a ton, works a treat.
Think it through. How else so you make a string that actually has the value &X ? By having the macro processor ignore strings in single quotes it is easy to prevent the macro process from messing up strings that just happen to look like macro code.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.