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 (July 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 6 Jul 2006 23:34:23 -0700
Reply-To:     David L Cassell <davidlcassell@MSN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         David L Cassell <davidlcassell@MSN.COM>
Subject:      Re: Converting an Age result
In-Reply-To:  <200607061426.k66AkLvW025847@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed

irinfigvam@YAHOO.COM wrote: > >I calculated Age in the following code: > > data studythrdDOB; > SET studythrdDOB; > age = (date() - DOB)/365.25 ; > run; > /************************************/ > > And I got an output AGE that looks like 3004969.5 > > Initial dob looked like 12jan1945. > Below is the fragment of proc contents. > > > > > # Variable Type Len Pos Format Informat >Label > >ャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャャ > 6 DOB Num 8 0 DATETIME20. DATETIME20. >DOB > > 68 age Num 8 288 > > > How can I convert the result Age in order it look like and Age (number >of years)? > > Thnk you in advance, > > Irin >

You included the prcise clue I needed. Look at the PROC CONTENTS output. DOB is a *datetime*, not a date. That means it is in seconds since Jan 1 1960, not in days. So first, do this:

datepart(DOB)

Now use this in your calculations.

Dividing by 365.25 is an okay approximation. Maybe. It totally depends on your 'business case'. What does an 'age' represent? Is it like my age, which only changes by 1 on my birthday? Is it supposed to be a continuous variable which increases every day?

I like Billy Kreuter's formula, which is a classic. Ian already discussed it.

Toby knows it. He just *pretended* to flub it so he could pad his number of posts by having to correct his 'mistake'. :-) :-) :-)

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement


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