BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
annypanny
Quartz | Level 8

How to Calculate the year which is 20 years from run date. E.g if today’s date is 11MAY2020, then this step will give year 2040.

I have used the below code but didn't find the solution.

 

data want;
set have;
do n=1 to 20 by +1;
date=intnx('year', &rundate, +n);
format date ddmmyyn8.;
output;
end;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

no need of do loop, please try the below code

 

data want;
date=intnx('year', today(), +20,'SAME');
format date ddmmyyn8.;
run;
Thanks,
Jag

View solution in original post

6 REPLIES 6
Jagadishkatam
Amethyst | Level 16

no need of do loop, please try the below code

 

data want;
date=intnx('year', today(), +20,'SAME');
format date ddmmyyn8.;
run;
Thanks,
Jag
ed_sas_member
Meteorite | Level 14

HI @annypanny 

You can retrieve the year which is 20 years from run date by using the INTNX function.
The modifier "S" tells SAS to pick the same date (-> so 11MAY2040).
For your other questions, could you please explain where do we find the collection name? For example, is Flexi 2040-42 (BLK) the name of the production dataset?
Best,
data have;
	format today_date date9.;
	today_date = today();
	year20 = year(intnx('year',today_date,20,"s"));
run;
annypanny
Quartz | Level 8
Hi thanks,
I have replied to another question.
PaigeMiller
Diamond | Level 26

Another possibility

 

year_in_future = year(today())+20;

--
Paige Miller
annypanny
Quartz | Level 8
thanks, it is solved. Can you help me in another question linked with this question.
https://communities.sas.com/t5/SAS-Programming/How-to-Calculate-this-steps/td-p/646588

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 571 views
  • 3 likes
  • 4 in conversation