The following excerpt is from an e-mail message I sent to suggest@sas.com. I know other people have suggested that we need a function designed specifically for computing ages, and I wanted to add my voice to that chorus.
“I would like to make a suggestion for Base SAS. SAS needs a function that is designed specifically for the purpose of computing ages.
Looking back, I can’t believe that I didn’t suggest this 25 years ago, but at that time the people I worked with were satisfied to compute ages by dividing by 365.25. It was approximate, but we knew it was approximate so that was ok. The problem with computing ages using YRDIF or INTCK is that they appear to be more precise and accurate than they actually are—and that’s risky.
Computing ages is exactly the kind of thing that should be in The Little SAS Book, but the recommended method for computing ages using INTCK is just too complicated for this book.
In addition, the fact that INTCK counts the number of months and divides by 12 to compute ages in years is a little funky, in my opinion. Some people do want to compute decimal ages, and it might not be obvious to them that they can’t just remove the INT function to get decimal ages from INTCK. And why should you have to use more than one function to do something as ordinary as computing ages anyway?
And then there is the whole issue of negative time ranges. I don’t know if computing negative time ranges is a valid idea or not, but I do know that INTCK and YRDIF will let you do it—and the results are not consistent with each other. If you can compute negative ages, then they should be valid and consistent.
So here is my suggestion for an AGE function. It’s syntax would be
AGE(start-date, end-date, units, decimal-places)
where
Start-date would be a SAS date value for the beginning of the time period.
End-date would be a SAS date value for the end of the time period. If end-date is before start-date, then a missing value would be returned. (So no negative ages would be computed.) The keyword TODAY could be substituted for the end-date to compute current age. TODAY would be the default which would be used if no end-date is specified.
Units could have the value of YEARS or MONTHS to compute age in either years or months. YEARS would be the default.
Decimal-places would be a number indicating the number of decimal places. A value of 0 would produce integer values of age. 1 would produce ages with one decimal place, 2 would produce two decimal places, and so on. The default would be integer values.
If someone wanted to compute current ages in integer years, their statement would be something like this
CurrentAge = AGE(BirthDate);
Computing ages should be that simple—with no nested functions, and no IF-THEN/ELSEs required. If you write a function like this, then we would be happy to add it to The Little SAS Book.”
When I sent the above message to suggest@sas.com, the good folks at SAS Technical Support responded to let me know that they had received my message and that they were aware of my suggestion. They did not say whether such a function is currently being developed, or whether they have any plans to develop such a function in the future. If you need to compute ages in SAS, then you might want to share with SAS Technical Support your own ideas for the perfect function for computing ages.
Update:
Since I originally wrote this blog post, a new option has been added for the YRDIF function. The AGE option fails to satisfy most of my suggestions listed here. However, it does compute accurate ages and that is a huge improvement! I am now happy to recommend this method for computing current age in integer years:
CurrentAge = INT( YRDIF(BirthDate, TODAY(), ‘AGE’));

