Hello,
ODS output text= statements must be in single quotes to get hyperlinks to work, but they must be in double quotes to get macro variables to resolve. So how do we do both in a single text= statement?
Normally for getting macro vars to resolve in single quotes, you could use something like %unquote(%str()), but we can't use functions in text= statements...I believe.
This is the formatting I'm using for the text= statement:
ods rtf text= '^S={URL="https://website"}This is the macro var I want to resolve: ¯ovar_here.';
Would appreciate any tips or workarounds if anyone has any ideas.
Thank you!!
That's not quite correct.
Use outer quotes that are double quotes and single quotes around the URL. This seems to work for me.
ods rtf file='C:\_localdata\temp\test.rtf' style=meadow;
%let test=mytest;
ods escapechar='^';
ods rtf text="^S={URL='https://website'}This is the macro var I want to resolve: &test.";
proc print data=sashelp.class;
run;
ods rtf close;
That's not quite correct.
Use outer quotes that are double quotes and single quotes around the URL. This seems to work for me.
ods rtf file='C:\_localdata\temp\test.rtf' style=meadow;
%let test=mytest;
ods escapechar='^';
ods rtf text="^S={URL='https://website'}This is the macro var I want to resolve: &test.";
proc print data=sashelp.class;
run;
ods rtf close;
Thanks to both of you! For some reason all the examples I saw put double quotes around the url itself and I assumed stupidly that it must be that way.
Whether macro variable references are resolved is determined by the outer quotes.
Not clear that you need to use double quotes instead of single quotes where your string has them,
ods rtf text= "^S={URL='https://website'}This is the macro var I want to resolve: &mvar.";
but if you do then just double them up.
ods rtf text= "^S={URL""https://website""}This is the macro var I want to resolve: &mvar.";
Or ask SAS to do it for you.
ods rtf text=%sysfunc(quote(^S={URL="https://website"}This is the macro var I want to resolve: &mvar.));
Thank you! Stupidly believed I had to use double quotes around the url and did not test single quotes there.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.