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
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;
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;
Thank you for the reply RW9 .
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 ?
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;
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 !
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 ?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.