Date: Thu, 11 Feb 1999 08:53:28 -0600
Reply-To: King Douglas <King_Douglas@AMRCORP.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From: King Douglas <King_Douglas@AMRCORP.COM>
Subject: Re: Analyst needs date :) -Reply
Content-Type: text/plain
Thanks to Fabrizio (whose solution I
prefer--repeated below), SPSS and others who
answered my query. Here's the SPSS Help Desk
solution to computing dates from within a DO
REPEAT, DO IF command stucture (the following
doesn't require the DO IF statement--a simple IF
command structure would suffice, but I needed to
compute additional variables not shown here):
DO REPEAT
P = "string1" "string2" "string3"
/Q = 12 1 2
/R = 3 13 23
/S = 1998 1999 1999.
DO IF strval= P.
COMPUTE dateval = DATE.MDY(Q,R,S).
END IF.
END REPEAT.
LIST STRVAL DATEVAL.
STRVAL DATEVAL
String1 12/03/1998
String2 01/13/1999
String3 02/23/1999
King Douglas
American Airlines
>>> Fabrizio Arosio <Fabrizio_Arosio@ROTTA.COM>
02/11/99 04:30am >>>
You can use the function DATE.MDY(m,d,y) to assign
a date to an SPSS
numeric date variable.
In your syntax, my suggestion is to use the
NUMERIC function to convert a
string date in a
numeric date:
DO REPEAT
P = "string1" "string2" "string3"
/Q = "1/23/1999" "1/24/1999" "1/25/1999".
DO IF strval= P.
COMPUTE dateval = NUMERIC(Q,ADATE10).
END IF.
END REPEAT.
FORMAT dateval (ADATE10).
LIST dateval.
Hope this helps you,
Fabrizio
King Douglas <King_Douglas@AMRCORP.COM> on
10/02/99 16.24.15
Please respond to King Douglas
<King_Douglas@AMRCORP.COM>
To: SPSSX-L@UGA.CC.UGA.EDU
cc: (bcc: Fabrizio Arosio/RRL/IT)
Subject: Analyst needs date :)
Hey, list members.
I usually avoid working with "dates" in SPSS
because they are often problematic. I convert
dates to strings or numbers (as days, months,
years), and recombine them, if and when necessary,
into a date variable. It is necessary in this
case.
What I want to do is add many SPSS date values
(e.g., 01/23/1999) depending on the value of
another (string) variable using something like DO
REPEAT (I already know this doesn't work--it's
just an example).
DO REPEAT
P = "string1" "string2" "string3"
/Q = 1/23/1999 1/24/1999 1/25/1999.
DO IF strval= P.
COMPUTE dateval = Q.
END IF.
END REPEAT PRINT.
EXECUTE.
If you know how to do this kind of thing with SPSS
date values, lay it on me! TIA
King Douglas