The SAS Output Delivery System and reporting techniques

Resolving macro variable inside ODS PDF text

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Resolving macro variable inside ODS PDF text

I am attempting to resolve a formatted macro variable inside ODS PDF text but am getting the error message below:-

 

  ERROR: More positional parameters found than defined.

 

If I remove the formatting from the 'total' it prints as expected, but it has to be comma formatted.

 

Code is below.  Can anyone help?

 

proc sql noprint;
select count(zip) format=comma10. into :total

from sashelp.zipcode;
quit; %put &total;

 

ods pdf file = 'c:\test.pdf';

ods pdf text = "This is the total: %left(&total)";

ods pdf close;


Accepted Solutions
Solution
‎10-15-2015 09:15 AM
Super User
Posts: 5,092

Re: Resolving macro variable inside ODS PDF text

You're getting that error because the %LEFT function sees something like this:

 

%left(   123,456)

 

The comma appears to %LEFT as marking the end of the first parameter and the start of the second parameter.

 

The simplest solution would be to get rid of %LEFT.  First, remove leading blanks from &TOTAL using:

 

%let total = &total;

 

Then you can simplify the later statement:

 

ods pdf text = "This is the total: &total";

 

Good luck.

View solution in original post


All Replies
Solution
‎10-15-2015 09:15 AM
Super User
Posts: 5,092

Re: Resolving macro variable inside ODS PDF text

You're getting that error because the %LEFT function sees something like this:

 

%left(   123,456)

 

The comma appears to %LEFT as marking the end of the first parameter and the start of the second parameter.

 

The simplest solution would be to get rid of %LEFT.  First, remove leading blanks from &TOTAL using:

 

%let total = &total;

 

Then you can simplify the later statement:

 

ods pdf text = "This is the total: &total";

 

Good luck.

Occasional Contributor
Posts: 16

Re: Resolving macro variable inside ODS PDF text

Worked brilliantly, thanks for your help!

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 574 views
  • 0 likes
  • 2 in conversation