I've a variable called Renewal_date and I've to create new variable(New_Renewal_date) with the year. If DDMM is past then I've to add 2019 and if it is current and future value then I've to add 2018.
Example:
Renewal_date New_Renewal_date
15jun 15jun2019
11sep 11sep2019
14sep 14sep2018
02jan 02jan2019
@Babloo wrote:
I've a variable called Renewal_date and I've to create new variable(New_Renewal_date) with the year. If DDMM is past then I've to add 2019 and if it is current and future value then I've to add 2018.
Example:
Renewal_date New_Renewal_date
15jun 15jun2019
11sep 11sep2019
14sep 14sep2018
02jan 02jan2019
First you have to obtain an actual month and day of month from the column named Renewal_date. Once you have that, the MDY function can append years to dates. Test if renewal date 2018 is in the past or in the future, then use MDY to get new_renewal_date.
Something like:
data want; set have; if input(cats(renewal_date,"2018"),date9.) > today()) then new_renewel_date=input(cats(renewel_date,"2019"),date9.); else renewel_date=input(cats(renewal_date,"2018"),date9.); run;
Not sure its a good idea though, if you run the same code tomorrow, you will likely get different results. Far better to have a baseline and compare against a fixed baseline rather than a moving "today" timepoint.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.