/ Published in: SAS
For proper calculation of human age using DOB and an as-of date.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Age Function */ proc fcmp outlib=sasuser.funcs.trial; function age (DOB, asOfDate); if DOB < asOfDate then return(floor((intck('month',DOB,asOfDate) - (day(asOfDate) < day(DOB))) / 12)); else return (_ERROR_); endsub; run; options cmplib = sasuser.funcs; data _null_; DOB = '15Feb2006'd; today = '27Mar2012'd; sd = age(DOB, today); put sd=; run;