Usage Note 36977: Using the YRDIF function to calculate age can give incorrect results in SAS® releases prior to 9.3
If you use the YRDIF function to calculate a person's age, you might get incorrect results. This function was designed for the Securities Industry to calculate interest for fixed income securities based on industry rules. Therefore, if you use this function in any other way, your calculation could be incorrect. SAS customers have reported incorrect results when using this function for calculating age. The function apparently does not take into account the extra day in leap years.
The following links present methods for correctly calculating age.
Sample 24567: Calculate a person's age
Sample 36788: Calculating a person's age using PROC FCMP
UPDATE TO THIS NOTE: 15JUL2011
A new option was added to YRDIF in SAS 9.3. This option is called AGE and can be used to calculate a person's age accurately.
Below is link to the 9.3 documentation for the function.
The YRDIF Function
Operating System and Release Information
| SAS System | Base SAS | Microsoft Windows 2000 Advanced Server | 8.2 TS2M0 | |
| OS/2 | 8.2 TS2M0 | |
| z/OS | 8.2 TS2M0 | |
| OpenVMS VAX | 8.2 TS2M0 | |
| Microsoft Windows 95/98 | 8.2 TS2M0 | |
| Microsoft Windows 2000 Datacenter Server | 8.2 TS2M0 | |
| Microsoft Windows 2000 Server | 8.2 TS2M0 | |
| Microsoft Windows 2000 Professional | 8.2 TS2M0 | |
| Microsoft Windows NT Workstation | 8.2 TS2M0 | |
| Microsoft Windows Server 2003 Datacenter Edition | 8.2 TS2M0 | |
| Microsoft Windows Server 2003 Enterprise Edition | 8.2 TS2M0 | |
| Microsoft Windows Server 2003 Standard Edition | 8.2 TS2M0 | |
| Microsoft Windows XP Professional | 8.2 TS2M0 | |
| Windows Millennium Edition (Me) | 8.2 TS2M0 | |
| 64-bit Enabled AIX | 8.2 TS2M0 | |
| 64-bit Enabled HP-UX | 8.2 TS2M0 | |
| 64-bit Enabled Solaris | 8.2 TS2M0 | |
| ABI+ for Intel Architecture | 8.2 TS2M0 | |
| AIX | 8.2 TS2M0 | |
| HP-UX | 8.2 TS2M0 | |
| IRIX | 8.2 TS2M0 | |
| Linux | 8.2 TS2M0 | |
| OpenVMS Alpha | 8.2 TS2M0 | |
| Solaris | 8.2 TS2M0 | |
| Tru64 UNIX | 8.2 TS2M0 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
A new option was added in 9.3 to calculate a person's age
| Type: | Usage Note |
| Priority: | |
| Topic: | SAS Reference ==> Functions ==> Date and Time ==> YRDIF
|
| Date Modified: | 2011-08-11 14:38:14 |
| Date Created: | 2009-08-25 13:47:21 |