BookmarkSubscribeRSS Feed
jskarda
Calcite | Level 5

We have a database with a date field in MMM-YY format.  Is there a method to convert to a sortable date into a new date column with the last day in the month specified.  JAN-19  to be 01/31/2019.  FEB-19 to be 02/28/2019.

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

Please try intnx

 

data have;
input date $;
newdate=intnx('month',input(cats('01-',date),anydtdte.),0,'end');
format newdate date9.;
cards;
JAN-19
Feb-19
;
Thanks,
Jag
ballardw
Super User

Or minor difference from @Jagadishkatam 

data have;
input date $;
newdate=intnx('month',input(date,monyy.),0,'end');
format newdate date9.;
cards;
JAN-19
Feb-19
;
jskarda
Calcite | Level 5
Thank you. Could you please return in the form of a statement?
proc sql;
update WORK.FILE
set COLUMNB=intnx('month',input(cats('01-',date),anydtdte.),0,'end');
run;

DATA in its original format is in a column named COLUMNA. It could contain
any month or year, but we would like the last day in any given month

Stored Value in COLUMNA='APR-19'
New value produced in COLUMNB should be April, 30, 2019 in a sortable format.