LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (May 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 24 May 2005 13:23:54 -0400
Reply-To:     "Sridhar, Kumar" <nsridhar@MEDAREX.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Sridhar, Kumar" <nsridhar@MEDAREX.COM>
Subject:      Re: Question on Proc SQL - correct age formula
Comments: To: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Content-Type: text/plain; charset="us-ascii"

You wrote < It handles all birthdates precisely except Jan 29, which is close but not perfect.>

Would I be right in presuming that you meant Feb.29?

Regards

Kumar

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Choate, Paul@DDS Sent: Tuesday, May 24, 2005 1:03 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Question on Proc SQL - correct age formula

Hi Kevin & Kumar -

YRDIF is close, but not perfect. Since the 366 vs 365 divisor is relative to the person's birthdate, not Jan 1, YRDIF still has a small error associated with it.

Wialliam Kreuter has provided a correct formula:

age = floor ((intck('month',birth,somedate) - (day(somedate) < day(birth))) / 12);

or the macro:

%macro age(date,birth); floor ((intck('month',&birth,&date) - (day(&date) < day(&birth))) / 12) %mend age;

(http://ftp.sas.com/techsup/download/sascomm/sascom-tt-4q98a.html)

It handles all birthdates precisely except Jan 29, which is close but not perfect.

Look around here:

SAS.COM http://search.sas.com/suppquery.html?col=suppsas&qt=Kreuter

SAS-L http://xrl.us/f7ou

regards

Paul Choate DDS Data Extraction (916) 654-2160

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Kevin Roland Viel Sent: Tuesday, May 24, 2005 7:53 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Question on Proc SQL

> But I have a question in regards to the difference > (and it maybe a nave question) but would you know why the difference > occurs?

Our concept of years of age typically mean the number of times something reach the month and day of its birth in the cycle of years. The discrepancy results from the integer representation of an approximation.

Some years have 366 days and some have 365. Since (approximately) every four years has 366, we say that, on average, a year is 365.25. Not every fourth year has 366, for instance 1900.

The YRDIF() function, will correctly divide by 366 or 365 as appropriate.

Regards,

Kevin

Kevin Viel Department of Epidemiology Rollins School of Public Health Emory University Atlanta, GA 30322


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