Date: Wed, 23 Mar 2005 22:58:03 -0500
Reply-To: Richard Ristow <firstname.lastname@example.org>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Richard Ristow <email@example.com>
Subject: Re: Converting multiple date variables to one composite variable
Content-Type: text/plain; charset="us-ascii"; format=flowed
At 05:08 PM 3/21/2005, Jake Gross wrote:
>I need some help converting multiple date variables into one variable
>I am working with data that has a separate variable for each month
>(example, date_var1=01-Jan-2002, dat_var2=01-Feb-2002, etcetera). So,
>I have 24 variables representing each month for 2 years.
This sounds like your variables simply give the first day of each
month, over a two-year period, as SPSS date values. That doesn't seem
very useful; is that really what you have? It sounds like the last 23
of the 24 convey no information at all.
>I want to convert these separate variables into one date variable that
>can be coded for each year (new_date_var=1 for 2002 and new_date_var=2
>for 2003, for example).
It sounds like you want the year part of "date_var1". If so,
COMPUTE new_date_var = XDATE.YEAR(date_var1).
For your example record, this will give new_date_var=2002. If you want
to count 2002 as year 1, etc., you could then write,
COMPUTE new_date_var = new_date_var - 2001.
>I know I can do this using DO IF ELSE statements for each month, but
>think there has to be a more efficient way.
What bothers me is that this suggestion ignores 23 of the 24 date
variables. So, is it true that those variables tell you nothing? Or am
I missing your point?