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

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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