Help using Base SAS procedures

Difference between Two date in years

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 118
Accepted Solution

Difference between Two date in years

hello,

I make the difference between two dates using this program.

data age;
set JOINT_FO;
age=caldt-FIRST_OFFER_DT;
run;

 

The program give me the difference in days but I want it in year or in fraction of year????


Accepted Solutions
Solution
‎12-15-2016 09:28 AM
Contributor
Posts: 33

Re: Difference between Two date in years

[ Edited ]

Many ways to do this, I've used intck and yrdif in the past!

 

Age = yrdif(FirstDate, SecondDate,'AGE');

 

View solution in original post


All Replies
Super User
Posts: 6,936

Re: Difference between Two date in years

Look at the extremely flexible INTCK function.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 6,936

Re: Difference between Two date in years

For the simplest calculation, just consider that a year has 365.24237 days (Gregorian calendar). So divide your difference in days by that.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎12-15-2016 09:28 AM
Contributor
Posts: 33

Re: Difference between Two date in years

[ Edited ]

Many ways to do this, I've used intck and yrdif in the past!

 

Age = yrdif(FirstDate, SecondDate,'AGE');

 

Frequent Contributor
Posts: 118

Re: Difference between Two date in years

thanks for your help guys
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1304 views
  • 1 like
  • 3 in conversation