Date: Tue, 2 Oct 2007 16:34:11 -0500
Reply-To: "Oliver, Richard" <roliver@spss.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Oliver, Richard" <roliver@spss.com>
Subject: Re: need to add leading zero to some values but not all.
In-Reply-To: A<47026302.7E13.0074.0@loyola.edu>
Content-Type: text/plain; charset="us-ascii"
No need to add the leading zero:
data list free /datestring (a8).
begin data
10211958
8131951
1012000
end data
compute #datenumber=number(datestring, f8).
compute #year=mod(#datenumber, 10000).
compute #day=mod(trunc(#datenumber/10000),100).
compute #month=trunc(#datenumber/1000000).
compute realDate=date.mdy(#month, #day, #year).
formats realDate (adate10).
list.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Martin Sherman
Sent: Tuesday, October 02, 2007 2:26 PM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: need to add leading zero to some values but not all.
Dear list: I have a variable that has values of 7 digits and 8 digits. The 7 digit needs a zero in front of the first number. The variable is a string which will be converted into a date once I get the zero in place. Advice appreciated. Could not find an answer at spsstools. net. thanks, martin sherman
|