BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Planck
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
TheShark
Obsidian | Level 7

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;

View solution in original post

6 REPLIES 6
LinusH
Tourmaline | Level 20

Try %left.

Data never sleeps
TheShark
Obsidian | Level 7

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;
Kurt_Bremser
Super User

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!

Astounding
PROC Star

Could this be happening because your default length is 15 instead of 14?  You are only filling 14 characters.

Planck
Obsidian | Level 7

Perfect,

 

Thank you for all your reply, it works

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2942 views
  • 6 likes
  • 5 in conversation