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 (June 1996)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 16 Jun 1996 22:57:07 -0700
Reply-To:     z2175v9y@atila.overnet.com.ar
Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:         "Hector E. Maletta" <hmaletta@OVERNET.COM.AR>
Subject:      Re: Compute Age var in SPSS win
Comments: To: Mbekou Valentin <mbekou@ERE.UMONTREAL.CA>

Mbekou Valentin wrote: > > Hi everyone > It is me again with my dummies questions. I am working on data collected > on 12th of october 1991. With the date of birth (DOB) variable entered in > dd-mm-yy format, how do I compute the variable Age (in years) for each > subject at that specific day? I am working with SPSS win 6.1. > Thanks in advance. > -- > Valentin Mbekou Departement de Psychologie Universite de Montreal > mbekou@ere.umontreal.ca

The following command can do the trick:

1. Define date of birth as a DATE type variable, called BIRTHDAY for instance, with the format dd-mm-yr. 2. Create another variable of the DATE type, call it TODAY, with the uniform value 12-10-1991. 3. Issue a compute command:

COMPUTE AGE = (CTIME.DAYS (TODAY - BIRTHDAY))/365.25.

The function CTIME.DAYS converts the time interval to days. You divide bny 365.25 to yield the time interval in years plus decimals. It is 365.25 and not 365, because of leap years (and this is only approximate, of course, but you dont need astronomical precision here, I assume).

Later you may convert the decimal part of AGE to months and days (extract the decimal part by subtracting the whole number of years, then multiply by 365 and divide by 12 to get the number of months to be added to the age in years). The residue can be treated the same way to obtain days. But the year+decimals form is handy for calculations and for using the variable in statistical procedures.

Other COMPUTE functions dealing with DATE variables can be helpful, though the explanation in the manuals is far from clear or complete (deliberately cryptical, you may think it is).

Good luck!


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