Sometimes people were asking for data and you just provided it to them. If it is an annual completed static data, you don’t have to do the date stamp to keep a record on when you retrieve the data from the system. However, if it is an operational ongoing data with day-to-day changes and also the data is not officially published for the year, you might want to keep a record of the date for reference.
The SAS code here basically provides a date format that you want to show on the Excel file name. The format code itself is quite complicated, but you don’t have to remember it at all. Just copy and paste. There are many variations to it. Then use macro functions %unquote and %sysfunc to get date and time as part of the file name.
proc format;
picture mydtfmt
low-high = ‘%Y_%0m_%0d_%0I%0M%p’ (datatype=datetime);
run;
PROC EXPORT DATA= Section
OUTFILE= “C:\Documents\My SAS Files(32)\9.3\Exce\section_%unquote(%sysfunc(datetime(),mydtfmt.)).xlsx”
DBMS=EXCEL REPLACE;
SHEET=”section”;
RUN;
Output:
In Windows Explorer,