| Date: | Thu, 8 Oct 2009 06:41:16 -0400 |
| Reply-To: | coxspss@cox.net |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | David Wright <coxspss@cox.net> |
| Subject: | Re: SPSS date transformation help |
| Content-Type: | text/plain; charset=UTF-8; format=flowed; delsp=no |
If it doesn't have to be a string you could convert it to a numeric with
leading zeros.
ALTER TYPE rdate (N6.0).
David
On Thu, Oct 8, 2009 at 4:24 AM, DorraJ Oet wrote:
> Hello Jazgul,
>
> My data is almost the same as yours but I figure that you might want
> to include data that has the following in red.
>
>
> 05-OCT-2009 09:12:28
> 05-OCT-2009 11:18:12
>
> 05-OCT-2009 12:39:45
> 05-OCT-2009 15:09:49
>
> 05-OCT-2009 15:45:22
> 05-OCT-2009 19:26:40
>
> 05-OCT-2009 20:14:04
> 10-OCT-2009 20:14:04
>
>
> This is because you will need to consider the fact that you might have
> dates that have 10-31 day.
>
> 05-OCT-2009 20:14:04 entries are fine because you will get 051009 but
> it cause a problem if you will to add a '0' in front of entries like
> 10-OCT-2009 20:14:04 which will give you 0101009 if your final date
> variable is of width a8.
>
> So maybe you can try this. If you still have problem understanding my
> syntax, do tell me.
>
> string daydraft month (a2) year (a4).
> compute daydraft=string(xdate.mday(date),f2).
> compute month=string(xdate.month(date),f2).
> compute year=string(xdate.year(date),f4).
> freq daydraft to year.
>
>
> compute daydraft2=xdate.mday(date).
> freq daydraft2.
>
> string day (a2).
> do if (daydraft2 lt 10).
> compute day=replace(daydraft,' ', '0').
> else if (daydraft2 ge 10).
> compute day=daydraft.
> end if.
> freq day.
>
> string datefinal (a6).
> compute datefinal=concat(day,month,substring(year,3,2)).
> freq datefinal.
>
> Regards
> Dorraj
>
> Date: Thu, 8 Oct 2009 09:47:40 +0200
> From: johnfhall@orange.fr
> Subject: Re: SPSS date transformation help
> To: SPSSX-L@LISTSERV.UGA.EDU
>
>
>
>
>
>
>
>
>
>
> Jazgul
>
> Bit outside my field I'm afraid, and it will take
> me too long to find out. Someone on the list will know. ViAnn
> Beadle, Jon Peck and Bruce Weaver usually give knowledgable
> replies. There was something a while back on converting seconds to
> years
> or vice versa, something like that, but I've deleted my
> copies
>
> John
>
> ----- Original Message -----
> From:
> Jazgul
> Ismailova
> To: johnfhall@orange.fr
> Sent: Thursday, October 08, 2009 8:55
> AM
> Subject: SPSS date transfromation
> help
>
> Hello John,
>
> Could you kindly help me wit hthe following
> task.
>
> I have a date in the following format:
>
> 05-OCT-2009 09:12:28
> 05-OCT-2009 11:18:12
>
> 05-OCT-2009 12:39:45
> 05-OCT-2009 15:09:49
>
> 05-OCT-2009 15:45:22
> 05-OCT-2009 19:26:40
>
> 05-OCT-2009 20:14:04
>
> What I need is this
>
> 051009
>
> 051009
> 051009
> 051009
>
> 051009
> 051009
> 051009
> I
> come up with the script:
>
> STRING rdate (A6).
> compute rdate= concat
> (string (xdate.mday (intend), f2.0), lpad (ltrim (string
> (xdate.month
> (intend), f2.0)), 2, "0"), substr (string (xdate.year (intend),
> f4.0), 3,
> 2)).
> EXE.
>
> But then I get just:
> 51009
>
> 51009
> 51009
> 51009
>
> 51009
> 51009
> 51009
>
> How
> can I add 0s in the day? So that it is 6 digit?
>
>
> Thank you in
> advance,
>
> Jazgul
>
> _________________________________________________________________
> Windows Live: Make it easier for your friends to see what you’re up to
> on Facebook.
>
> http://www.microsoft.com/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-sg:SI_SB_2:092009
=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
|