I\'m just trying to concatenate two quoted macro variables but there doesn\'t seem to be an easy way.
Say we have:
%LET VAR1=\"This is not the greate
I'm going to paraphrase Joe's 'real answer' which is - do not store quotes in the macro variable. Single and double quotes in the macro language are no different to any other character. What you should do is delay introducing the quotes until you actually need them. This will result in much cleaner, more flexible, easier to read, and bug-free code.
Code:
Notice I've removed the quotes and to concatenate the strings I'm just listing them one after the other:
%LET VAR1=This is not the greatest song in the world;
%LET VAR2=this is just a tribute.;
%LET TRIBUTE=&VAR1 &VAR2;
Example 1
No quotes are needed to print out the desired string as we are using a %put
statement in this first example - for this reason I left the quotes out:
%PUT &TRIBUTE;
Output :
This is not the greatest song in the world this is just a tribute.
Example 2
Quotes are required because we are now in data-step land:
data _null_;
put "&TRIBUTE";
run;
Output :
This is not the greatest song in the world this is just a tribute.
Note that both of these examples assume you don't actually want to print the quotes to the screen.