Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!

How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

Accepted Solution Solved
Reply
Contributor sm4
Contributor
Posts: 51
Accepted Solution

How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

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


Accepted Solutions
Solution
‎01-30-2018 06:02 PM
Super User
Posts: 24,028

Re: How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

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


All Replies
Solution
‎01-30-2018 06:02 PM
Super User
Posts: 24,028

Re: How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

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;

 

 

Contributor sm4
Contributor
Posts: 51

Re: How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

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.

 

 

Super User
Super User
Posts: 8,290

Re: How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

[ Edited ]

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

 

Contributor sm4
Contributor
Posts: 51

Re: How to use both hyperlinks AND macro variables in a single ODS RTF text= statement

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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