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

Hi everyone,

So I got a bit stuck with this problem, I have the following coding:

%let path=C:\Users\User1\Documents\My SAS Files\Project;

%let person=%sysget(USERNAME);

%let systime_s = %sysfunc(timepart(%substr(&SysProcessId,1,16)x),time8.);

%let sysdate_t = &sysdate;

  ods _all_ close;

  ods listing close;

  ods pdf style=BStyle bookmarklist=hide file="&path./output_test&sysdate_t.&systime_s.&person..pdf" startpage = never;

  ods pdf; 

....

....

So what I want to achieve is to have the file name look something like this: output_test08JAN15123448User1.pdf - that is filename=output_test(todays date)(Todays time with seconds)(Username).pdf

Do you have any suggestions how to do this ?

Someone suggested the call symputx function but I'm not sure how to use it in this case.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, formats are at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm

You may however need to do:  %sysfunc(compress(%sysfunc(time(),time8.),:.)) so

file="&path./output_test%sysfunc(date(),date9.)_t%sysfunc(compress(%sysfunc(time(),time8.),:.))_s%sysget(USERNAME).pdf" startpage = never;

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

You can use the %sysfunc syntax, with the date() and time() function and put them into whatever format you want.

%let path=C:\Users\User1\Documents\My SAS Files\Project;

ods _all_ close;

ods listing close;

ods pdf style=BStyle bookmarklist=hide file="&path./output_test%sysfunc(date(),date9.)_t%sysfunc(time(),tod5.)_s%sysget(USERNAME).pdf" startpage = never;

ods pdf; 

mjheever
Obsidian | Level 7

Thank you for the reply RW9 Smiley Wink.

It almost works perfectly, I think I just have to adjust the format of sysfunc(time(),tod5.) since currently it gives output_test08JAN2015_t13 and messes with the format of the file.

Can you recommend a format which will be in the form of 132750 (hhmmss) rather than the usual 13:27:50 (hh:mm:ss) format ?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, formats are at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001263753.htm

You may however need to do:  %sysfunc(compress(%sysfunc(time(),time8.),:.)) so

file="&path./output_test%sysfunc(date(),date9.)_t%sysfunc(compress(%sysfunc(time(),time8.),:.))_s%sysget(USERNAME).pdf" startpage = never;

mjheever
Obsidian | Level 7

I really need to scratch up with my date/time formats :smileyshocked:

It works like a charm now RW9, thank you very much.

Give this man a Bells !

Ksharp
Super User

The file separator is \ (for windows) in &path, while it is / (for Unix) in file=" " , you can't combine them together .What OS is your SAS under ?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 4690 views
  • 6 likes
  • 3 in conversation