Hi. I am trying to compute the age of the subjects in our database at
the time of their office visit. We have both the date of office visit and their date of birth in our dataset. However, both of these dates are entered as 3 separate variables; month day and year. Could someone please offer suggestions as to what is the easiest way to determine their age? Thanks, Jenny Steffes |
Hi Jenny,
You have two choices here, if you have V13 or above you can use the date and time wizard to combine these variables via the gui interface, Alternatively I would look at raynalds website, http://www.spsstools.net/LearningSyntax.htm#DT2 Prior to this for syntax needed HtH Mike -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jennifer Steffes Sent: 12 December 2006 14:15 To: [hidden email] Subject: Computing age when dates are in 3 different variables Hi. I am trying to compute the age of the subjects in our database at the time of their office visit. We have both the date of office visit and their date of birth in our dataset. However, both of these dates are entered as 3 separate variables; month day and year. Could someone please offer suggestions as to what is the easiest way to determine their age? Thanks, Jenny Steffes ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by Jennifer Steffes
www.statisticsdoc.com
Stephen Brand Jenny, What version of SPSS are you running? If you have version 13 or higher, the date-time wizard is extremely helpful. You can save the syntax that is generated by the wizard for future applications as well. This computation can also be carried out in earlier versions, by computing the birthdate from the three variables, and the difference between the present date and the birth date, but it is more cumbersome. Best, Stephen Brand For personalized and professional consultation in statistics and research design, visit www.statisticsdoc.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Jennifer Steffes Sent: Tuesday, December 12, 2006 9:15 AM To: [hidden email] Subject: Computing age when dates are in 3 different variables Hi. I am trying to compute the age of the subjects in our database at the time of their office visit. We have both the date of office visit and their date of birth in our dataset. However, both of these dates are entered as 3 separate variables; month day and year. Could someone please offer suggestions as to what is the easiest way to determine their age? Thanks, Jenny Steffes |
In reply to this post by Jennifer Steffes
I do have SPSS 14 and it worked perfect--thanks!
>>> "Statisticsdoc" <[hidden email]> 12/12/2006 8:52:33 AM >>> www.statisticsdoc.com Stephen Brand Jenny, What version of SPSS are you running? If you have version 13 or higher, the date-time wizard is extremely helpful. You can save the syntax that is generated by the wizard for future applications as well. This computation can also be carried out in earlier versions, by computing the birthdate from the three variables, and the difference between the present date and the birth date, but it is more cumbersome. Best, Stephen Brand For personalized and professional consultation in statistics and research design, visit www.statisticsdoc.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Jennifer Steffes Sent: Tuesday, December 12, 2006 9:15 AM To: [hidden email] Subject: Computing age when dates are in 3 different variables Hi. I am trying to compute the age of the subjects in our database at the time of their office visit. We have both the date of office visit and their date of birth in our dataset. However, both of these dates are entered as 3 separate variables; month day and year. Could someone please offer suggestions as to what is the easiest way to determine their age? Thanks, Jenny Steffes |
In reply to this post by Jennifer Steffes
Jenny,
You should be able to use the YRMODA function to get both dates and then the difference. YRMODA Function: Convert year, month, and day to a day number. The number returned is the number of days since October 14, 1582 (day 0 of the Gregorian calendar). Since YRMODA yields the number of days instead of seconds, you can not display it in date format unless you convert it to the number of seconds. If you subtract 2 YRMODA days (and this has worked forever in SPSS--as far back as some of the SPSSx versions) you'll get the days between the dates--to get age, do formula like COMPUTE visitdate=YRMODA(visityr,visitmo,visitda). COMPUTE dob=YRMODA(dobyr,dobmo,dobda). COMPUTE AGE=TRUNC((visitdate-dob)/365.25). ** truncate because age doesn't change until the birthday, and 365.25 to account for leap years. Melissa -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Statisticsdoc Sent: Tuesday, December 12, 2006 8:53 AM To: [hidden email] Subject: Re: [SPSSX-L] Computing age when dates are in 3 different variables www.statisticsdoc.com Stephen Brand Jenny, What version of SPSS are you running? If you have version 13 or higher, the date-time wizard is extremely helpful. You can save the syntax that is generated by the wizard for future applications as well. This computation can also be carried out in earlier versions, by computing the birthdate from the three variables, and the difference between the present date and the birth date, but it is more cumbersome. Best, Stephen Brand For personalized and professional consultation in statistics and research design, visit www.statisticsdoc.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of Jennifer Steffes Sent: Tuesday, December 12, 2006 9:15 AM To: [hidden email] Subject: Computing age when dates are in 3 different variables Hi. I am trying to compute the age of the subjects in our database at the time of their office visit. We have both the date of office visit and their date of birth in our dataset. However, both of these dates are entered as 3 separate variables; month day and year. Could someone please offer suggestions as to what is the easiest way to determine their age? Thanks, Jenny Steffes PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for the use of the addressee. If you are not the designated recipient, or an employee or agent authorized to deliver such transmittals to the designated recipient, you are hereby notified that any dissemination, copying or publication of this transmittal is strictly prohibited. If you have received this transmittal in error, please notify us immediately by replying to the sender and delete this copy from your system. You may also call us at (309) 827-6026 for assistance. |
Free forum by Nabble | Edit this page |