Date conversion

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Date conversion

David Hitchin
I have a data file with dates recorded as strings, e.g. 11/06/2010 and I
need to convert them to "real" dates.

COMPUTE dayno=number(EVENT,DATE11).
does this, but dayno is displayed in numeric format. It is easy to click on
the "variable view" of the datasheet and alter the type there, but is there
any way of accomplishing this step as a command within a sytax file?

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (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
Reply | Threaded
Open this post in threaded view
|

Re: Date conversion

Lemon, John S.

I would use the Date time wizard under the ‘Transform’ window to create the new variable and paste the generated syntax

 

Best Wishes

 

John S. Lemon

DIT ( Directorate of Information Technology ) - Student Liaison Officer

University of Aberdeen

Edward Wright Building: Room G86a ( please note new room )

 

Tel:  +44 1224 273350

 

Diary ( Free / Busy )

 

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Hitchin
Sent: 11 June 2010 09:27
To: [hidden email]
Subject: Date conversion

 

I have a data file with dates recorded as strings, e.g. 11/06/2010 and I

need to convert them to "real" dates.

 

COMPUTE dayno=number(EVENT,DATE11).

does this, but dayno is displayed in numeric format. It is easy to click on

the "variable view" of the datasheet and alter the type there, but is there

any way of accomplishing this step as a command within a sytax file?

 

=====================

To manage your subscription to SPSSX-L, send a message to

[hidden email] (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



The University of Aberdeen is a charity registered in Scotland, No SC013683.
Reply | Threaded
Open this post in threaded view
|

Re: Date conversion

Ruben Geert van den Berg
In reply to this post by David Hitchin
Dear David,
 
I think
 
format dayno(adate10).
 
does the trick.
 
HTH,

Ruben van den Berg
Consultant Models & Methods
TNS NIPO
Email: [hidden email]
Mobiel: +31 6 24641435
Telefoon: +31 20 522 5738
Internet: www.tns-nipo.com



 

> Date: Fri, 11 Jun 2010 09:26:50 +0100
> From: [hidden email]
> Subject: Date conversion
> To: [hidden email]
>
> I have a data file with dates recorded as strings, e.g. 11/06/2010 and I
> need to convert them to "real" dates.
>
> COMPUTE dayno=number(EVENT,DATE11).
> does this, but dayno is displayed in numeric format. It is easy to click on
> the "variable view" of the datasheet and alter the type there, but is there
> any way of accomplishing this step as a command within a sytax file?
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (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


New Windows 7: Find the right PC for you. Learn more.
Reply | Threaded
Open this post in threaded view
|

Re: Date conversion

Ruben Geert van den Berg
In reply to this post by David Hitchin
Oh, that reminds me: alternatively, I think you could use
 
data list free/str(a12).
begin data
11/06/2010
end data.
 
alter type str(edate10).

format str(adate10).
 
If you alter type directly to adate10, then '11' will be the month and '06' the day and I somehow have the feeling this is not what you intend.
 
HTH,

Ruben van den Berg
Consultant Models & Methods
TNS NIPO
Email: [hidden email]
Mobiel: +31 6 24641435
Telefoon: +31 20 522 5738
Internet: www.tns-nipo.com



 

> Date: Fri, 11 Jun 2010 09:26:50 +0100
> From: [hidden email]
> Subject: Date conversion
> To: [hidden email]
>
> I have a data file with dates recorded as strings, e.g. 11/06/2010 and I
> need to convert them to "real" dates.
>
> COMPUTE dayno=number(EVENT,DATE11).
> does this, but dayno is displayed in numeric format. It is easy to click on
> the "variable view" of the datasheet and alter the type there, but is there
> any way of accomplishing this step as a command within a sytax file?
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (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


New Windows 7: Simplify what you do everyday. Find the right PC for you.