I have a SAS script that outputs a SAS .xpt file. I currently use the PROC COPY method of generating this because the required name includes dashes and is longer than eight characters (which I understand is the name limit when using xport).
My code is roughly as follows:
LIBNAME TempSrc "C:\Temp";
LIBNAME xportout xport 'C:\Temp\1234-AB-FileOut_Name_.xpt';
PROC IMPORT datafile="C:\Temp\FileIn.csv"
out=mydata
dbms=dlm replace;
DELIMITER= ",";
getnames=yes;
options ExtendObsCounter=no;
RUN;
DATA TempSrc.SasFile;
set work.mydata
RUN;
PROC COPY in=TempSrc out=xportout memtype=data;
select stdy7673;
RUN;
I have recently been required to include a timestamp in the output file name.
I have these macros to generate the date and time as required:
%let today=%sysfunc(date(), date9.);
%let now=%sysfunc(time(), time5.);
%let now=%sysfunc(compress(&now, :));
I have not been able to incorporate into the LIBNAME with any success, though.
Neither of the following has worked:
LIBNAME xportout xport 'C:\Temp\1234-AB-File_Name_&today.&now..xpt';
LIBNAME xportout xport 'C:\Temp\1234-AB-File_Name_' || &today. || &now. '.xpt';
How can I include the datetime in the .xpt filename?