```Date: Mon, 10 Mar 2008 01:57:43 +0000 Reply-To: iw1junk@COMCAST.NET Sender: "SAS(r) Discussion" From: Ian Whitlock Subject: Re: decimal age macro needed Comments: cc: RolandRB Roland, %macro age(date,birth); /* kreuter's age macro */ floor ((intck('month',&birth,&date) - (day(&date) < day(&birth))) / 12) %mend age; %macro exactage(dt,bd) ; /* return age + part of year to next birthday */ %age(&dt,&bd) + ( (&dt-intnx("year",bd,%age(dt,bd),"S")) /(intnx("year",bd,%age(dt,bd)+1,"S")- intnx("year",bd,%age(dt,bd),"S"))) %mend exactage ; data _null_ ; bd = "29feb2000"d ; do dt = "27feb2001"d to "2mar2001"d ; exactage = %exactage(dt,bd) ; put bd= date9. dt= date9. exactage= ; end ; bd = "25apr2000"d ; do dt = "23apr2001"d to "27apr2001"d ; exactage = %exactage(dt,bd) ; put bd= date9. dt= date9. exactage= ; end ; run ; Ian Whitlock =============== Date: Sat, 8 Mar 2008 23:10:52 -0800 Reply-To: RolandRB Sender: "SAS(r) Discussion" From: RolandRB Organization: http://groups.google.com Subject: decimal age macro needed Comments: To: sas-l Content-Type: text/plain; charset=ISO-8859-1 Can somebody point me to a macro that does an exact decimal age (I don't want to see "365.25" anywhere) ? What I want is an exact solution to a floating point decimal age. The fractional part should be the number of days beyond the floor of the age in years compared with the number of days to the next birthday, compensated for by leap years. And all in a simple call like this. http://www.datasavantconsulting.com/roland/age.sas If somebody has a suitable macro and wants it webbing then I'll do just that. At the moment, my spare time commitments prohibit it. ```

Back to: Top of message | Previous page | Main SAS-L page