age from dob

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

age from dob

maria azzopardi
hi,
I am doing my dissertation on spss.I have a data set containing the date
of birth.From the date of birth I want to calculate the age with SPSS as
well.Can you help me finding the solution please?

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: age from dob

Albert-Jan Roskam
Hi Maria,

I believe this should work:
* sample data.
data list free / dob (date).
begin data
02-JAN-2007
28-NOV-1974
19-APR-1945
01-NOV-2000
13-JAN-1966
end data.

* actual code.
* the division is necessary to make the conversion
from seconds to years (365.25 allows for leapyears).
* 'trunc' truncates the age to an integer.
numeric age (f3.0).
compute age = trunc ((date.dmy(01,01,2007) - dob) /
3600 / 24 / 365.25).
variable label age 'Age at January 1, 2007'.
exe.

Cheers & merry x-mas!!
Albert-Jan


--- maria azzopardi <[hidden email]> wrote:

> hi,
> I am doing my dissertation on spss.I have a data set
> containing the date
> of birth.From the date of birth I want to calculate
> the age with SPSS as
> well.Can you help me finding the solution please?
>
> =====================
> To manage your subscription to SPSSX-L, send a
> message to
> [hidden email] (not to SPSSX-L), with no
> body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send
> the command
> INFO REFCARD
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: age from dob

Peck, Jon
Note that the formula below will give the approximate age, but for the exact ages, look at the DATEDIFF function.

HTH,
Jon Peck

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Albert-jan Roskam
Sent: Wednesday, December 12, 2007 1:43 AM
To: [hidden email]
Subject: Re: [SPSSX-L] age from dob

Hi Maria,

I believe this should work:
* sample data.
data list free / dob (date).
begin data
02-JAN-2007
28-NOV-1974
19-APR-1945
01-NOV-2000
13-JAN-1966
end data.

* actual code.
* the division is necessary to make the conversion
from seconds to years (365.25 allows for leapyears).
* 'trunc' truncates the age to an integer.
numeric age (f3.0).
compute age = trunc ((date.dmy(01,01,2007) - dob) /
3600 / 24 / 365.25).
variable label age 'Age at January 1, 2007'.
exe.

Cheers & merry x-mas!!
Albert-Jan


--- maria azzopardi <[hidden email]> wrote:

> hi,
> I am doing my dissertation on spss.I have a data set
> containing the date
> of birth.From the date of birth I want to calculate
> the age with SPSS as
> well.Can you help me finding the solution please?
>
> =====================
> To manage your subscription to SPSSX-L, send a
> message to
> [hidden email] (not to SPSSX-L), with no
> body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send
> the command
> INFO REFCARD
>


Cheers!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Did you know that 87.166253% of all statistics claim a precision of results that is not justified by the method employed? [HELMUT RICHTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: age from dob

Richard Ristow
In reply to this post by maria azzopardi
At 01:17 PM 12/11/2007, maria azzopardi wrote:

>I have a data set containing the date of birth. From the date of
>birth I want to calculate the age with SPSS.

Let me point out a few complications (who, me?).

There are at least two standard definitions of "age", partly  Among
because the 'year' is not a fixed-length unit of time.

For a uniformly increasing 'age', you have to measure in a
fixed-length unit like seconds or days and then (if desired) convert
approximately to years. That's Albert-jan's solution, and probably
what you want to do if you're using age as, say, an independent
variable in a regression. As Jon Peck noted, it *is* approximate.
That's not from a deficiency in the calculation, but because a
uniformly-increasing 'age' can't exactly match the varying-length 'year'.

In civil and colloquial use, 'age' is in integral years. It increases
by one year on each anniversary of the birth date, regardless of
whether the preceding 'year' has 365 or 366 days. That's what
DATEDIFF(birthdate,nowdate,"years") gives, as Jon Peck suggested --
from the Command Syntax Reference, "One 'year' is defined as the same
month and day, one year before or after the second date
argument."

Use whichever is right for your project, and best wishes,
Richard

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD