Return to Snippet

Revision: 62493
at February 27, 2013 07:15 by csrsen


Initial Code
/*
   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;

Initial URL


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

Initial Title
person age function

Initial Tags


Initial Language
SAS