person age function


/ Published in: SAS
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.