Newsgroups: comp.soft-sys.stat.spss Date: 2003-01-17 13:03:20 PST In response to a discussion on this list a few years ago, I wrote the following syntax to compare 3 traditional ways to compute *age* at admission. I recommend the second way. I don't have the time at the moment to cut down the old syntax so I just added a few example cases using 1/1/2003 as the reference date. I your application all cases would have the same "admission" date, so you could just put it in a compute. compute admsndat= date.mdy(1,1,2003). Hope this helps. *Art **Art*@DrKendall.org Social Research Consultants University Park, MD USA new file. * this program compares different ways of finding the *age*. *note that cases 1, 2, and 6 have the same Gregorian month and day for birth and admission. *but notice the julian day-within-the-year in variable jborn. *make up some data. data list list / birthdat(adate10) admsndat(adate10) wanted (f3). begin data. 4/10/1931 4/10/2002 71 4/10/1933 4/10/2002 69 4/10/1932 4/7/2002 69 4/10/1932 4/8/2002 69 4/10/1932 4/9/2002 69 4/10/1932 4/10/2002 70 4/10/1932 4/11/2002 70 4/10/1932 4/12/2002 70 4/10/1932 4/13/2002 70 1/1/2000 1/1/2003 3 1/1/2001 1/1/2003 2 1/1/2002 1/1/2003 1 12/31/2002 1/1/2003 0 1/2/1933 1/1/2003 69 1/1/1933 1/1/2003 70 end data. numeric age1 age2 age3 (f3). *method 1. COMPUTE age1 = trunc(CTIME.DAYS(admsndat - birthdat) / 365.25) . * method2 see if birthday in current year has occurred yet. compute bmo = xdate.month(birthdat). compute bdom = xdate.mday(birthdat). compute byr = xdate.year(birthdat). compute amo = xdate.month(admsndat). compute adom = xdate.mday(admsndat). compute ayr = xdate.year(admsndat). compute nearbirt = date.mdy(bmo,bdom,ayr). do if nearbirt le admsndat. compute age2 = ayr-byr. else if nearbirt gt admsndat. compute age2 = ayr-byr-1. end if. formats nearbirt (adate10) age2 (f3). * method 3 jdate way from earlier responder. compute age3 = xdate.year(admsndat) - xdate.year(birthdat) - ( xdate.jdate(birthdat) > xdate.jdate(admsndat) ). compute age3 = xdate.year(admsndat) - xdate.year(birthdat) - ( xdate.jdate(birthdat) gt xdate.jdate(admsndat) ). compute jadm = xdate.jdate(admsndat) . compute jborn = xdate.jdate(birthdat) . formats age3 jborn jadm(f3). numeric line (f2). compute case = $casenum. list /variables = case admsndat birthdat wanted age1 age2 age3 jborn jadm. Susan T wrote: > Hi! I'm using SPSS 10.1 Win, and have a quick question > that I've been stuck on today. I have a data file that > includes birthdates in Date format (dd-mmm-yyyy). > I want to calculate an *age* for each person as of > January 1, 2003. > > Can someone help me? Thanks! > > Susan > >