Date: Tue, 14 Jan 1997 13:50:10 -0600
Reply-To: marso@spss.com
Sender: "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From: David Marso <marso@SPSS.COM>
Organization: SPSS Inc
Subject: Re: Date Format as YYMMDD????
Content-Type: text/plain; charset=us-ascii
Jeff,
Here are three different ways to do this: Take your pick.
David Marso
data list / date1 to date5 1-30 .
begin data
120196110295010345040989111587
110176110685101045121480041982
end data.
NUMERIC #M1 to #M5 #D1 TO #D5 #Y1 TO #Y5.
DO REPEAT X=date1 to date5
/ M=#M1 to #M5 / D=#D1 TO #D5 / Y=#Y1 TO #Y5 .
COMPUTE M=TRUNC(X/10000).
COMPUTE Y=MOD(X,100).
COMPUTE D=(X-M*10000-Y)/100.
COMPUTE X=DATE.MDY(,D,Y).
FORMATS X(ADATE).
END REPEAT.
LIST.
DATE1 DATE2 DATE3 DATE4 DATE5
12/01/1996 11/02/1995 01/03/1945 04/09/1989 11/15/1987
11/01/1976 11/06/1985 10/10/1945 12/14/1980 04/19/1982
* OR * .
data list / date1 to date5 1-30 .
begin data
120196110295010345040989111587
110176110685101045121480041982
end data.
NUMERIC #M1 to #M5 #D1 TO #D5 #Y1 TO #Y5.
DO REPEAT X=date1 to date5.
COMPUTE X=DATE.MDY(TRUNC(X/10000),
(X-TRUNC(X/10000)*10000-MOD(X,100))/100,
MOD(X,100)).
FORMATS X(ADATE).
END REPEAT.
LIST.
* OR my personal favorite*.
data list / date1 to date5 1-30 .
begin data
120196110295010345040989111587
110176110685101045121480041982
end data.
STRING #(A10).
DO REPEAT X=DATE1 TO DATE5.
COMPUTE #=STRING(X,F6).
COMPUTE
X=NUMBER(CONCAT(SUB(#,1,2),'/',SUB(#,3,2),'/',SUB(#,5,2)),ADATE).
FORMAT X (ADATE).
END REPEAT.
LIST.
Jeff Hayes wrote:
>
> Hey,
>
> I'm using SPSS 6.1.3 for Win. I'm trying to feed a vector of dates from
> SPSS to another program. SPSS provides for a multitude of different
> date formats (ddmmyyyy, Q yyyy, dd.mm.yy, etc.), but the one i need is
> yymmdd. That is, December 2, 1972 becomes 721202. No spaces or dots or
> slashes between the day, month, or year. Is there an easy way to do
> this that I'm not smart enuff to figure out or is there some relatively
> brief command syntax that someone could pass on to me or am i just
> screwed?
>
> Thanks in advance.
>
> Jeff
> --
> ++++++++++++++++++++++++++++++++++++++++
> Jeff Hayes
> University of Chicago
> Department of Political Science
> (H) 773-955-3998 (W) 773-702-8080
> http://www.spc.uchicago.edu/users/haye1/
> ++++++++++++++++++++++++++++++++++++++++
|