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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 4234 views
  • 6 likes
  • 3 in conversation