Functions and CALL Routines 
Category:  Date and Time 
Syntax  
Arguments  
Details  
The Basics  
Method of Calculation for Day Count Basis (30/360)  
Examples  
See Also  
References 
Syntax 
DATDIF(sdate,edate,basis) 
specifies a SAS date value that identifies the starting date.
Tip:  If sdate falls at the end of a month, then SAS treats the date as if it were the last day of a 30day month. 
specifies a SAS date value that identifies the ending date.
Tip:  If edate falls at the end of a month, then SAS treats the date as if it were the last day of a 30day month. 
specifies a character string that represents the day count basis. The following values for basis are valid:
specifies a 30day month and a 360day year, regardless of the actual number of calendar days in a month or year.
A security that pays interest on the last day of a month will either always make its interest payments on the last day of the month, or it will always make its payments on the numerically same day of a month, unless that day is not a valid day of the month, such as February 30. For more information, see Method of Calculation for Day Count Basis (30/360).
Alias:  '360' 
uses the actual number of days between dates. Each month is considered to have the actual number of calendar days in that month, and each year is considered to have the actual number of calendar days in that year.
Alias:  'Actual' 
uses the actual number of calendar days in a particular month, and 360 days as the number of days in a year, regardless of the actual number of days in a year.
Tip:  ACT/360 is used for shortterm securities. 
uses the actual number of calendar days in a particular month, and 365 days as the number of days in a year, regardless of the actual number of days in a year.
Tip:  ACT/365 is used for shortterm securities. 
Details 
The DATDIF function has a specific meaning in the securities industry, and the method of calculation is not the same as the actual day count method. Calculations can use months and years that contain the actual number of days. Calculations can also be based on a 30day month or a 360day year. For more information about standard securities calculation methods, see References.
Note: When counting the number of days in a month, DATDIF always includes the starting date and excludes the ending date.
To calculate the number of days between two dates, use the following formula:
where
Y2 
specifies the year of the later date. 
Y1 
specifies the year of the earllier date. 
M2 
specifies the month of the later date. 
M1 
specifies the month of the earlier date. 
D2 
specifies the day of the later date. 
D1 
specifies the day of the earlier date. 
Because all months can contain only 30 days, you must adjust for the months that do not contain 30 days. Do this before you calculate the number of days between the two dates.
The following rules apply:
If the security follows the EndofMonth rule, and D2 is the last day of February (28 days in a nonleap year, 29 days in a leap year), and D1 is the last day of February, then change D2 to 30.
If the security follows the EndofMonth rule, and D1 is the last day of February, then change D1 to 30.
If the value of D2 is 31 and the value of D1 is 30 or 31, then change D2 to 30.
If the value of D1 is 31, then change D1 to 30.
Examples 
In the following example, DATDIF returns the actual number of days between two dates, as well as the number of days based on a 30day month and a 360day year.
data _null; sdate='16oct78'd; edate='16feb96'd; actual=datdif(sdate, edate, 'act/act'); days360=datdif(sdate, edate, '30/360'); put actual= days360=; run;
SAS Statements  Results 

put actual=; 
6332 
put days360=; 
6240 
See Also 

References 
Securities Industry Association. 1994. Standard Securities Calculation Methods  Fixed Income Securities Formulas for Analytic Measures, Volume 2. New York: Securities Industry Association. 
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.