Hi All!
May I have suggestions on how to format a SAS date to this 12-05-2018 15:56. I need dashes not slashes 🙂 THANKS!
proc format;
picture datetimeStamp
low-high='%Y-%0m-%0d %0H:%0M' (datatype=datetime);
run;
%put %sysfunc(datetime(), datetimeStamp.);
documentation reference:
To make a DATE look xx-xx-xxxx use either MMDDYYD or DDMMYYD format, depending on whether your example was supposed to represent the Dec 5th or 12th of May.
Why does you example include a time part? Do you want to make a DATETIME value instead of DATE value?
proc format;
picture datetimeStamp
low-high='%Y-%0m-%0d %0H:%0M' (datatype=datetime);
run;
%put %sysfunc(datetime(), datetimeStamp.);
documentation reference:
You could keep the values as DATETIME and make user defined picture format to display it the way you want.
Or you could create a character variable that displays the value the way you want.
length char_var $16;
char_var=catx(' ',put(datepart(datetime_var),mmddyyd10.),put(timepart(datetime_var),tod5.));
But you probably do NOT want to use MM-DD-YYYY (or DD-MM-YYY either) to display your datetime values. Which ever one you pick will confuse half of the people reading the reports. Plus the character string version will not sort in chronological order.
Use YYYY-MM-DD instead.
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 16. 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.