Hi,
I'm trying to save my SAS Table and first I want to rename it with the datestamp.
This is my code:
PROC FORMAT;
PICTURE datestamp(default=15)other='%Y%0m%0d%0H%0M%0S' (datatype=datetime);
RUN;
data FILENAME_%sysfunc(datetime(),datestamp);
set FILENAME;
RUN;
proc copy inlib=work outlib=output ;
select FILENAME_%sysfunc(datetime(),datestamp);
run;
But it's not working because before the datestamp I have a blank...Something like "FILENAME_ 20170110163415"
And I don't understand why. Do you know?
Thanks
I would set a macro variable for the datestamp and then call that.
PROC FORMAT;
PICTURE datestamp(default=15)other='%Y%0m%0d%0H%0M%0S' (datatype=datetime);
RUN;
%let datestamp=%sysfunc(datetime(), datestamp.);
data FILENAME_&datestamp.;
set FILENAME;
RUN;
Use this
data _null_;
call symput('datestamp',strip(put(datetime(),datestamp.)));
run;
and use &datestamp in place of your %sysfunc's.
Try %left.
I would set a macro variable for the datestamp and then call that.
PROC FORMAT;
PICTURE datestamp(default=15)other='%Y%0m%0d%0H%0M%0S' (datatype=datetime);
RUN;
%let datestamp=%sysfunc(datetime(), datestamp.);
data FILENAME_&datestamp.;
set FILENAME;
RUN;
Also keep in mind that datetime() always returns the CURRENT date&time, so the results of your %sysfunc's would be different if the program ran in more than one second!
Could this be happening because your default length is 15 instead of 14? You are only filling 14 characters.
Perfect,
Thank you for all your reply, it works
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.