- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-15-2018 08:01 AM
(7622 views)
Hi all,
i have the following data set:
ID MONTH YEAR
x 2 2015
y 4 2015
z 10 2016
Now i want to create a date variable with given month and year as well as the last day of the month:
Data test;
Set test;
Date=MDY(MONTH,31,YEAR);
format date ddmmyy10.;
run;
But this only works for ID z because October consists of 31 days, but February (28) and April (30) not.
Is there any function, which automatically generates the day information as last day for the given month?
Thank you for ur effort!
Mike
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the intnx() function to automate this:
data test;
set test;
date = intnx('month',mdy(month,1,year),0,'e');
format date ddmmyy10.;
run;