DATA Step, Macro, Functions and more

How do I Get %Sysfunc to work in a PDF File Name

Accepted Solution Solved
Reply
Contributor CEG
Contributor
Posts: 25
Accepted Solution

How do I Get %Sysfunc to work in a PDF File Name

Hi,

 

I can't get the month and year to appear in the ODS PDF FILE, but it works throughout the program.

 

%let today = %sysfunc( TODAY());

%let month = %sysfunc( PUTN(&TODAY - 28,MONNAME3.));

%let year = %sysfunc( PUTN(&TODAY - 28,YEAR4.));

 

ODS PDF FILE = 'C:&month&year_VideoCounts.pdf';

 

 

Thanks!

CEG


Accepted Solutions
Solution
‎07-12-2017 12:10 PM
Super User
Super User
Posts: 6,498

Re: How do I Get %Sysfunc to work in a PDF File Name

The macro processor ignores string quoted using single quote characters. Use double qoute characters instead.  When you put characters after the macro variable name that are valid characters to use in a macro variable name you need to tell SAS where your variable name ends. You use the period for this.

ODS PDF FILE = "C:&month.&year._VideoCounts.pdf";

View solution in original post


All Replies
Solution
‎07-12-2017 12:10 PM
Super User
Super User
Posts: 6,498

Re: How do I Get %Sysfunc to work in a PDF File Name

The macro processor ignores string quoted using single quote characters. Use double qoute characters instead.  When you put characters after the macro variable name that are valid characters to use in a macro variable name you need to tell SAS where your variable name ends. You use the period for this.

ODS PDF FILE = "C:&month.&year._VideoCounts.pdf";
Contributor CEG
Contributor
Posts: 25

Re: How do I Get %Sysfunc to work in a PDF File Name

Perfect! Thanks!


Super User
Super User
Posts: 7,392

Re: How do I Get %Sysfunc to work in a PDF File Name

Not sure why you need all that code, just do:

ods pdf file="c:\%sysfunc(date(),dtmonyy7.)_VideoCounts.pdf";

 

Contributor CEG
Contributor
Posts: 25

Re: How do I Get %Sysfunc to work in a PDF File Name

Thanks!



It is a lot easier.


☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 74 views
  • 0 likes
  • 3 in conversation