Previous Page | Next Page

Functions and CALL Routines

YRDIF Function



Returns the difference in years between two dates.
Category: Date and Time

Syntax
Arguments
Examples
See Also

Syntax

YRDIF(sdate,edate,basis)


Arguments

sdate

specifies a SAS date value that identifies the starting date.

edate

specifies a SAS date value that identifies the ending date.

basis

identifies a character constant or variable that describes how SAS calculates the date difference. The following character strings are valid:

'30/360'

specifies a 30-day month and a 360-day year in calculating the number of years. Each month is considered to have 30 days, and each year 360 days, regardless of the actual number of days in each month or year.

Alias: '360'
Tip: If either date falls at the end of a month, it is treated as if it were the last day of a 30-day month.
'ACT/ACT'

uses the actual number of days between dates in calculating the number of years. SAS calculates this value as the number of days that fall in 365-day years divided by 365 plus the number of days that fall in 366-day years divided by 366.

Alias: 'Actual'
'ACT/360'

uses the actual number of days between dates in calculating the number of years. SAS calculates this value as the number of days divided by 360, regardless of the actual number of days in each year.

'ACT/365'

uses the actual number of days between dates in calculating the number of years. SAS calculates this value as the number of days divided by 365, regardless of the actual number of days in each year.


Examples

In the following example, YRDIF returns the difference in years between two dates based on each of the options for basis.

data _null_;
   sdate='16oct1998'd;
   edate='16feb2003'd;
   y30360=yrdif(sdate, edate, '30/360');
   yactact=yrdif(sdate, edate, 'ACT/ACT');
   yact360=yrdif(sdate, edate, 'ACT/360');
   yact365=yrdif(sdate, edate, 'ACT/365');
   put y30360= yactact= yact360= yact365=;
run;

SAS Statements Results
put y30360=;
put yactact=;
put yact360=;
put yact365=;
4.333333333
4.3369863014
4.4
4.3397260274


See Also

Functions:

DATDIF Function

Previous Page | Next Page | Top of Page