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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

2 REPLIES 2
Astounding
PROC Star

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.

kimdukes77
Obsidian | Level 7

Worked brilliantly, thanks for your help!

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
  • 2 replies
  • 2393 views
  • 0 likes
  • 2 in conversation