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 (October 1998)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 6 Oct 1998 14:39:56 -0500
Reply-To:     "Lucas, Gail" <glucas@SPSS.COM>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From:         "Lucas, Gail" <glucas@SPSS.COM>
Subject:      Re: How to calculate age
Comments: To: "Martin F. Sherman" <MFS@VAX.LOYOLA.EDU>

Martin,

First, you need to change your numeric variable into a date variable. Here is some sample syntax that should work.

Replace DATE2 with the name you want the new date variable to be, replace "numericvar" with the name of the variable that has the date in a numeric format.

STRING BDATE (A4).

COMPUTE BDATE=STRING(numericvar,N4).

STRING MO (A2).

STRING YR (A2).

COMPUTE MO=(substr(BDATE,1,2)).

COMPUTE YR=(substr(BDATE,3,2)).

COMPUTE DATE2=number(concat(MO,"/", YR),MOYR).

EXECUTE.

FORMATS DATE2 (MOYR).

EXE.

Then, in order to compute the age (I'm assuming you want the age based on the day their data was collected):

COMPUTE AGE=(CTIME.DAYS(DATE2-BIRTHDATE))/365.25.

DATE2 would be the variable for the date the data was collected, and birthdate would be the day they were born.

If you wanted their age based on today, you would need to first:

COMPUTE TODAY=XDATE.DATE($TIME).

Which would create a variable, TODAY that is today's date. Then, substitute TODAY for DATE2.

If you have any questions, feel free to email me.

Gail SPSS Technical Support

-----Original Message----- From: Martin F. Sherman [mailto:MFS@VAX.LOYOLA.EDU] Sent: Tuesday, October 06, 1998 1:44 PM To: SPSSX-L@UGA.CC.UGA.EDU Subject: How to calculate age

I have dates presented in two different ways. One date came in as numeric 1148 which stands for November, 1948. How would I convert this to a date format. The other date came in as date data - 11/01/48. One date represents the day the data was collected while the other date is the birthdate of participant. I want to calculate their age and just can't remember how to do it.

Thanks for any assistance

Martin Sherman

MFS@VAX.loyola.edu


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