## Difference between Two date in years

Solved
Frequent Contributor
Posts: 126

# 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: 35

## 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');``

All Replies
Super User
Posts: 10,239

## Re: Difference between Two date in years

Look at the extremely flexible INTCK function.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 10,239

## 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
How to convert datasets to data steps
How to post code
Solution
‎12-15-2016 09:28 AM
Contributor
Posts: 35

## 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: 126