|
Per Jon's suggestion, the syntax below will compute Age in years.
You can find the Date and Time wizard on the Transform menu. The system variable $TIME contains the current date. * 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. * Date and Time Wizard: Age. COMPUTE Age=DATEDIF($TIME, dob, "years"). VARIABLE LABEL Age. VARIABLE LEVEL Age (SCALE). FORMATS Age (F5.0). VARIABLE WIDTH Age(5). EXECUTE. Anthony Babinec -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Peck, Jon Sent: Wednesday, December 12, 2007 3:54 AM To: [hidden email] Subject: Re: age from dob 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 ===================== 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 |
| Free forum by Nabble | Edit this page |
