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 2004)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 30 Jun 2004 09:02:22 -0400
Reply-To:     Dr Julius Kitutu <jmm+@pitt.edu>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Dr Julius Kitutu <jmm+@pitt.edu>
Subject:      Re: date computation (6- decimal places needed)
Comments: To: Art@DrKendall.org
In-Reply-To:  <40E2B214.4@verizon.net>
Content-Type: text/plain; charset="us-ascii"

I had send the appended message to Paul...but hope it is an alternative to what Kendall is suggesting. Julius

Hi Paul, I do not know the format of your date variables, but if you have specific dates like mm/dd/yyyy, for both variables, then you can try the following syntax:

COMPUTE agerece = (XDate.Tday(intervie) - XDate.Tday(birth_da))/365.24.

With this kind of computation, you can have as many decimal places as you wish. Good luck. Julius

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Art Kendall Sent: Wednesday, June 30, 2004 8:29 AM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Re: date computation (6- decimal places needed)

I have modified a small age calculation demo I have. I added the age in days and the age as fractional. note that the age as fractional is inaccurate because of leap days.

Would age in days serve you as close to what you want? Wouldn't that be more than enough accuracy even if you were talking about neonates?

Cut-and-paste then run the syntax at the end of this message.

Hope this helps.

Art Art@DrKendall.org Social Research Consultants University Park, MD USA (301) 864-5570 new file.

*make up some data. data list list / caseid (f2) birthdat(adate10) refdate(adate10) wanted (f3). begin data. 01 4/10/1931 4/10/2002 71 02 4/10/1933 4/10/2002 69 03 4/10/1932 4/7/2002 69 04 4/10/1932 4/8/2002 69 05 4/10/1932 4/9/2002 69 06 4/10/1932 4/10/2002 70 07 4/10/1932 4/11/2002 70 08 4/10/1932 4/12/2002 70 09 4/10/1932 4/13/2002 70 10 1/1/2000 1/1/2003 3 11 1/1/2001 1/1/2003 2 12 1/1/2002 1/1/2003 1 13 12/31/2002 1/1/2003 0 14 1/2/1933 1/1/2003 69 16 1/1/1933 1/1/2003 70 16 1/1/1899 1/1/2000 101 end data. numeric age (f3) agedays (f10)agefract (f17.6). compute agedays = ctime.days (refdate-birthdat). compute agefract= agedays/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(refdate). compute adom = xdate.mday(refdate). compute ayr = xdate.year(refdate). compute nearbirt = date.mdy(bmo,bdom,ayr). do if nearbirt le refdate. compute age = ayr-byr. else if nearbirt gt refdate. compute age = ayr-byr-1. end if. list /variables = caseid birthdat refdate wanted age agedays agefract.

Paul Dickson wrote:

>Hi servers > >We are using the following data computation syntax. The problem is that it is >rounding ages up and down to '0' decimal places. We were hoping to get the >syntax to create new ages based on 6 decimal places to facilitate optimal coding > >Thanks in advance > >Paul > >COMPUTE agerece = xdate.year(intervie) - xdate.year(birth_da). >EXECUTE . > > >


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