11-13-2016 05:10 PM
Within SAS Enterprise Guide i've set up a automated process to export an excel file to a file.
At the moment it replaces it's self every time the query runs. However i don't wish it to do this, i would like it if it was a new file every time and was named to show the date and time the file exported for auditing reasons.
an example of what i would like is...
Thank you in advance for any help you could provide. I love SAS as it really helps my role but i don't use it enough to understand it as well as i know you guys do.
All the best
11-13-2016 07:37 PM
How are you controlling the name of the output file?
You can create two macro variables that hold the date and time in the respective formats and then use them in the name.
file_name = "name&date._&time";
%let cdate=%sysfunc(today(), ddmmyyn8.); %put &cdate.; *this isnt correct format, you need to find the one that doesnt have colons; %let ctime=%sysfunc(time(), time4.)); %put &ctime.;
11-14-2016 03:19 AM
My favorite for creating control variables is to do it in a data step and use call symput:
data _null_; call symput('cdate',put(date(),ddmmyyn8.)); timestr = put(time(),tod5.); call symput('ctime',substr(timestr,1,2)!!substr(timestr,4,2)); run; %put &cdate.; %put &ctime.;
Note that the tod. format outputs a leading zero for single-digit hours (what the time. format does not do).
In a data step I can hack away using simple data step syntax without having to repeatedly use %sysfunc or %eval.