Update:
Since I originally wrote this blog post, a new option has been added for the YRDIF function. The AGE option is not the easy-to-use option that I dreamed of. 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’));
However, you should be aware that there are still situations where an alternate method may be better than YRDIF. You should define exactly what your requirements are, and test different methods (such as INTCK) to see which method best meets your needs.
The original blog post:
In all the long history of The Little SAS Book: A Primer (four editions, five if you count the Revised Second Edition) we have removed only three topics from the book. We dropped PROC COPY and PROC PLOT (that’s PLOT, not GPLOT or SGPLOT) because they had become largely obsolete. Now we have removed the YRDIF function, but this situation is different. For the first time ever, we have removed a topic because it doesn’t work.
The YRDIF function has been removed from The Little SAS Book: A Primer, Fourth Edition, starting with the third printing, because it does not compute accurate ages. (YRDIF never appeared in earlier editions.) In defense of YRDIF I have to point out that it does work the way it was designed to work; but YRDIF, it turns out, was never designed to compute ages. Specifically, ages computed using the YRDIF function may be incorrect if the starting or ending date falls in a leap year, and the ending date is the person’s birthday. Of course, this situation doesn’t happen all that often—but it does happen. So, if you need really accurate ages, then you can’t use YRDIF.
We considered substituting some other method for computing ages (such as INTCK), but it turns out that not only are those methods too complicated to squeeze into the tiny space we had, they also come with their own limitations and problems. We were forced to conclude that currently there is no single definitive method for computing ages in SAS. If you need to compute ages in SAS, the best you can do is to choose the one that has the fewest problems for your particular situation. After much debate, Lora Delwiche and I felt that we had no choice but to simply remove YRDIF from our book.
As a result of all this, we have written a paper, “Computing Ages in SAS: The Removal of the YRDIF Function from The Little SAS Book: A Primer, Fourth Edition.” This paper explains how YRDIF really works, and then discusses alternate methods for computing ages. You can download this paper by clicking here.