Date: Sun, 16 Jun 1996 22:57:07 -0700
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
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
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).