Posted By

csrsen on 02/27/13


Tagged

AGE sas


Versions (?)

person age function


 / Published in: SAS
 

For proper calculation of human age using DOB and an as-of date.

  1. /*
  2.   Age Function
  3. */
  4.  
  5. proc fcmp outlib=sasuser.funcs.trial;
  6. function age (DOB, asOfDate);
  7. if DOB < asOfDate then
  8. return(floor((intck('month',DOB,asOfDate) - (day(asOfDate) < day(DOB))) / 12));
  9. else
  10. return (_ERROR_);
  11. endsub;
  12. run;
  13.  
  14. options cmplib = sasuser.funcs;
  15.  
  16. data _null_;
  17. DOB = '15Feb2006'd;
  18. today = '27Mar2012'd;
  19.  
  20. sd = age(DOB, today);
  21.  
  22. put sd=;
  23. run;

Report this snippet  

You need to login to post a comment.