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
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.