The SAS Output Delivery System and reporting techniques

How to reference a macro variable in ODS RTF TEXT= ?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

How to reference a macro variable in ODS RTF TEXT= ?

I have a program that I need to run multiple times to produce reports for multiple school districts (using ODS PDF). I use the following to title my pages.

Before running my program,

%LET DISTNAME = Example;

Within my program,

TITLE1 "&DISTNAME.".;

This works fine for me. I would also like to add some descriptive text using ODS PDF TEXT= and mention the district name in the text. How do I do that?

ODS PDF TEXT = '^S={just=center font=("Times New Roman",14PT,Bold)} Report produced for &DISTNAME. ISD';

is not working.


Accepted Solutions
Solution
‎06-22-2012 12:30 AM
Frequent Contributor
Posts: 95

Re: How to reference a macro variable in ODS RTF TEXT= ?

I see why. Font name needs to be enclosed in single quotes when the overall text enclosed in double quotes.

Please see the example below.

%LET DISTNAME = Example;

ods escapechar='^';

TITLE1 "&DISTNAME.";

ods pdf file='d:\temp\test.pdf';

proc print data=sashelp.class;

run;

ODS PDF TEXT = "^S={just=center font=('Times New Roman',14PT,Bold)} Report produced for &DISTNAME. ISD";

%* ODS PDF TEXT = "^S={just=center font=(""Times New Roman"",14PT,Bold)} Report produced for &DISTNAME. ISD"; //* This would work, too */

ods pdf close;

View solution in original post


All Replies
Frequent Contributor
Posts: 95

Re: How to reference a macro variable in ODS RTF TEXT= ?

Can you try enclosing in double quotes instead of single?

ODS PDF TEXT = "^S={just=center font=("Times New Roman",14PT,Bold)} Report produced for &DISTNAME. ISD";

Occasional Contributor
Posts: 10

Re: How to reference a macro variable in ODS RTF TEXT= ?

No, that didn't work either ...

Solution
‎06-22-2012 12:30 AM
Frequent Contributor
Posts: 95

Re: How to reference a macro variable in ODS RTF TEXT= ?

I see why. Font name needs to be enclosed in single quotes when the overall text enclosed in double quotes.

Please see the example below.

%LET DISTNAME = Example;

ods escapechar='^';

TITLE1 "&DISTNAME.";

ods pdf file='d:\temp\test.pdf';

proc print data=sashelp.class;

run;

ODS PDF TEXT = "^S={just=center font=('Times New Roman',14PT,Bold)} Report produced for &DISTNAME. ISD";

%* ODS PDF TEXT = "^S={just=center font=(""Times New Roman"",14PT,Bold)} Report produced for &DISTNAME. ISD"; //* This would work, too */

ods pdf close;

Occasional Contributor
Posts: 10

Re: How to reference a macro variable in ODS RTF TEXT= ?

Alpay, that worked, thank you!

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 1800 views
  • 1 like
  • 2 in conversation