BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

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

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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

 

 

--
Paige Miller
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 801 views
  • 1 like
  • 3 in conversation