| Date: | Thu, 29 Jul 2004 13:41:55 -0600 |
| Reply-To: | Richard Read Allen <peakstat@WISPERTEL.NET> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Richard Read Allen <peakstat@WISPERTEL.NET> |
| Subject: | Re: how to calculate age from dob? |
|
| In-Reply-To: | <D7C367F57CB5464DBAE92B06E84E7915BCE83F@m-ex1.hlm.ad.moffit
t.usf.edu> |
| Content-Type: | text/plain; charset="us-ascii"; format=flowed |
|---|
I believe that the yrdif function also properly accounts for leap years.
Does anyone know any differently?
Thanks,
Richard
At 03:31 PM 7/29/2004 -0400, Cuthbertson, David wrote:
>To account properly for leap years, use the following macro which return
>age as an integer:
>
>%macro agemac(brthdat,curdate);
> floor((intck('month',&brthdat,&curdate)-(day(&curdate)<day(&brthdat)))/12)
> %mend;
>
>Example:
>
>data example;
>today=today();
>birthday=mdy(7,12,64);
>age=%agemac(birthday,today);
>
>David Cuthbertson, M.S.
>Biostatistician/Associate in Biostatistics
>Moffitt Cancer Center at the
>University of South Florida
>12902 Magnolia Drive
>Tampa, FL 33612
>desk: (813) 632-1326
>fax: (813) 632-1334
>email: cuthbedd@moffitt.usf.edu
>
> >Date: Thu, 29 Jul 2004 11:00:12 -0600
> >From: Richard Read Allen <peakstat@WISPERTEL.NET>
> >Subject: Re: how to calculate age from dob?
> >
> >Rusty,
> >
> >Lately, I've taken a liking for the yrdif function for calculating age:
> >
> > Age=int(yrdif(DOB,NowDate,'ACT/ACT'));
> >
> >Richard
> >
> >At 04:28 PM 7/29/2004 +0000, Rusty Shackleford wrote:
> >>I need to calculate a person's age. I have a numeric dob var that
> >>stores the date of birth of a person, and I've been doing this:
> >>
> >> %let nowyear = 2004;
> >>
> >> data dd;
> >> set dd;
> >> length age 8.;
> >> age = &nowyear - year(dob);
> >> run;
> >>
> >>This method requires updating the nowyear macro var each time the year
> >>changes, and the age results are off based on the current month.
> >>
> >>Is there a SAS function that returns the current date? All general
> >>date/time/age commentary is welcome.
> >>
> >>Thanks!
> >>
> >>
> >>--
> >>Give and take free stuff: http://freecycle.org
>######################################################################
>This transmission may be confidential or protected from disclosure and
>is only for review and use by the intended recipient. Access by
>anyone else is unauthorized. Any unauthorized reader is hereby
>notified that any review, use, dissemination, disclosure or copying of
>this information, or any act or omission taken in reliance on it, is
>prohibited and may be unlawful. If you received this transmission in
>error, please notify the sender immediately. Thank you.
>
>######################################################################
|