Here is what I have
data have;
input year month;
infile datalines missover;
datalines;
2020 1
2020 2
2020 3
;
Keen to want below:
31Jan2020
29Feb2020
31Mar2020
Thanks in advance
data want;
set have;
date = mdy(month, 1, year);
date_month_end = intnx('month', date, 0, 'e');
format date: date9.;
run;
@ywon111 wrote:
Here is what I have
data have;
input year month;
infile datalines missover;
datalines;
2020 1
2020 2
2020 3
;
Keen to want below:
31Jan2020
29Feb2020
31Mar2020
Thanks in advance
data want;
set have;
date = mdy(month, 1, year);
date_month_end = intnx('month', date, 0, 'e');
format date: date9.;
run;
@ywon111 wrote:
Here is what I have
data have;
input year month;
infile datalines missover;
datalines;
2020 1
2020 2
2020 3
;
Keen to want below:
31Jan2020
29Feb2020
31Mar2020
Thanks in advance
how about this
data want;
set have;
dmy=intnx ('month',mdy(month,1,year),0,'E');
format dmy date9.;
run;
One way:
data have;
input year month;
infile datalines missover;
dateval = intnx('month',mdy(month,1,year),0,'E');
format dateval date9.;
datalines;
2020 1
2020 2
2020 3
;
The MDY function uses month, day and year values to create a date, in this case using 1 for day as every month has a day 1. The INTNX function then adjusts that date to the end of that current month, 'month' being the interval, 0 being the current month to adjust the date value and 'E' to set the end of the interval.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.