BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sm4
Quartz | Level 8 sm4
Quartz | Level 8

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: &macrovar_here.';

Would appreciate any tips or workarounds if anyone has any ideas.

 

Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

 

 

View solution in original post

4 REPLIES 4
Reeza
Super User

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;

 

 

sm4
Quartz | Level 8 sm4
Quartz | Level 8

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.

 

 

Tom
Super User Tom
Super User

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

 

sm4
Quartz | Level 8 sm4
Quartz | Level 8

Thank you! Stupidly believed I had to use double quotes around the url and did not test single quotes there. 

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1328 views
  • 1 like
  • 3 in conversation