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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2185 views
  • 0 likes
  • 3 in conversation