Date: Mon, 10 Mar 2008 01:57:43 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: decimal age macro needed
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 <rolandberry@HOTMAIL.COM>
Sender: "SAS(r) Discussion"
From: RolandRB <rolandberry@HOTMAIL.COM>
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.
|