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.
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.
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.