LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 10 Mar 2008 06:39:39 -0500
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: decimal age macro needed
Comments: To: iw1junk@comcast.net
In-Reply-To:  <031020080157.14921.47D49597000460BD00003A49220730079305029A06CE9907@comcast.net>
Content-Type: text/plain; charset=ISO-8859-1

Your macro yields different results form YRDIF('ACTUAL'). From the description of YRDIF I would think that it doing the correct calculation. What do you think?

'ACT/ACT' uses the actual number of days between dates in calculating the number of years. SAS calculates this value as the number of days that fall in 365-day years divided by 365 plus the number of days that fall in 366-day years divided by 366.

On Sun, Mar 9, 2008 at 8:57 PM, Ian Whitlock <iw1junk@comcast.net> wrote: > 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. >


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