Hi all,
Is there a SAS format to make the date appearing as shown below:
04-Sep-2017
14-Jun-2015
21-May-2016
Thanks
zimcom
Try
date11.;
data test;
input date :date11.;
format date date11.;
cards;
04-Sep-2017
14-Jun-2015
21-May-2016
;
Try
date11.;
data test;
input date :date11.;
format date date11.;
cards;
04-Sep-2017
14-Jun-2015
21-May-2016
;
I checked but not sure if there is any such format, but if you need the date in that format probably you can try the below code with prxchange function which generates a character variable of date in the expected format.
data have;
input date:date10.;
new=prxchange('s/(\d{1,2})(\w{3})(\d{4})/$1-$2-$3/',-1,strip(put(date,date9.)));
format date date9.;
cards;
04-Sep-2017
14-Jun-2015
21-May-2016
;
date11.;
works perfect!
Thank you!
@Jagadishkatam wrote:
I checked but not sure if there is any such format, but if you need the date in that format probably you can try the below code with prxchange function which generates a character variable of date in the expected format.
data have; input date:date10.; new=prxchange('s/(\d{1,2})(\w{3})(\d{4})/$1-$2-$3/',-1,strip(put(date,date9.))); format date date9.; cards; 04-Sep-2017 14-Jun-2015 21-May-2016 ;
This looks like a case of using a tool one is more familiar with. Proc Format has a lot of options for making custom formats if one such as Date11 didn't work. Consider if the OP had wanted @ characters instead of dashes [admittedly not a likely need but to illustrate]:
proc format library=work; Picture mydatefmt (default=11) low-high= '%0d@%b@%Y' (datatype=date); run; data _null_; x='23JAN2019'd; put x= mydatefmt.; run;
So with the available format we don't have to modify the data set, just use the new format for the procedure output.
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.