Hi, I'd like to make a picture format of the date, but it should be in proper case. See samples below:
Date_Field New_Date_Format
29MAR2020 29-Mar
01JAN2020 1-Jan
I'm exporting these to excel, so I prefer to maintain the date formats. Thanks.
If this is more about getting a specific format in Excel then below demonstrates how to use a style for defining such a format.
data have;
input Date_Field:date9.;
format Date_Field date9.;
some_other_var1=_n_;
some_other_var2='ABC';
datalines;
29MAR2020
01JAN2020
;
options missing=' ';
ods listing close;
ods excel file='~/test/test.xlsx';
proc print data=have;
var some_other_var1;
var Date_Field / style(column)={tagattr='format: dd-mmm'};
var some_other_var2;
run;
ods excel close;
ods listing;
The SAS custom format would be:
Proc format library=work; picture ddmon low - high ='%d-%3B' (datatype=date); ; run; data example; x = '29Mar2020'd; y = '01Jan2020'd; put x= ddmon. +1 y= ddmon.; run;
Custom date formats like this may not work as intended when used with graphs though.
The quotes in the Picture statement must be single quotes and the case of the letters is important.
I have no idea if Excel will honor this either.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.