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.
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.