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.

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1847 views
  • 0 likes
  • 3 in conversation