I have the variables like Renewal_day and Renewal_month as follows and I want to calculate the Renewal_year. Variable
Renewal year can be calculated by using the variables Renewal_day and Renewal_month. If Renewal_day and Renewal_month values are past while comparing with today date value then Renewal_year should populate the value 2019 else it should be 2018.
| Renewal_day | Renewal_month | Renewal_year |
| 1 | 2 | 2019 |
| 8 | 4 | 2019 |
| 16 | 8 | 2018 |
| 4 | 11 | 2018 |
| 6 | 5 | 2019 |
Appreciate if someone of you guide me here.
Hello!
- This should cover your requirements. Set year to this year (year(today())).
- Add a year if month is past or month is this month but date is past.
data renewal_dates;
renewal_day = 1;
renewal_month = 2;
output;
renewal_day = 8;
renewal_month = 4;
output;
renewal_day = 16;
renewal_month = 8;
output;
renewal_day = 4;
renewal_month = 11;
output;
renewal_day = 6;
renewal_month = 5;
output;
run;
data output;
set renewal_dates;
renewal_year = year(today());
if renewal_month < month(today()) then renewal_year = renewal_year + 1;
else if renewal_month = month(today()) and renewal_day < day(today()) then renewal_year = renewal_year + 1;
run;Kind regards,
Calle
[Edited]
Something like this?
Renewal_year = year(today()) + ( mdy (Renewal_month, Renewal_day, year(today()) < today() );
year = year(today());
if mdy(month,day,year) < today() then year + 1;
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.