date problem

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

date problem

drfg2008
SPSS20 / Win

I have a csv-file with the following date format:

2007-03-17 13:00:00


I couldn't find a way to import it in SPSS as a date format (either while importing it from csv or as a function after being imported as a string, or any other solution)

Thanks for some help
Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: date problem

David Marso
Administrator
Two approaches:
data list /x (A19).
BEGIN DATA
2007-03-17 13:00:00
end data.
COMPUTE DATEX=NUMBER(CONCAT(SUBSTR(X,9,2),SUBSTR(X,5,4),SUBSTR(X,1,4),SUBSTR(X,11)),DATETIME).
FORMAT DATEX (DATETIME).
list.

data list /D (SDATE) T (TIME).
BEGIN DATA
2007-03-17 13:00:00
end data.
COMPUTE DT=D+T.
FORMAT DT (DATETIME).
list.
HTH, David
--
drfg2008 wrote
SPSS20 / Win

I have a csv-file with the following date format:

2007-03-17 13:00:00


I couldn't find a way to import it in SPSS as a date format (either while importing it from csv or as a function after being imported as a string, or any other solution)

Thanks for some help
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: date problem

David Marso
Administrator
In reply to this post by drfg2008
Two approaches:
data list /x (A19).
BEGIN DATA
2007-03-17 13:00:00
end data.
COMPUTE
DATEX=NUMBER(CONCAT(SUBSTR(X,9,2),SUBSTR(X,5,4),SUBSTR(X,1,4),SUBSTR(X,11)),DATETIME).
FORMAT DATEX (DATETIME).
list.

data list /D (SDATE) T (TIME).
BEGIN DATA
2007-03-17 13:00:00
end data.
COMPUTE DT=D+T.
FORMAT DT (DATETIME).
list.
HTH, David
--

drfg2008 wrote:

>
> SPSS20 / Win
>
> I have a csv-file with the following date format:
>
> 2007-03-17 13:00:00
>
>
> I couldn't find a way to import it in SPSS as a date format (either while
> importing it from csv or as a function after being imported as a string,
> or any other solution)
>
> Thanks for some help
>


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/date-problem-tp4990196p4990282.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: date problem

drfg2008
In reply to this post by David Marso
thanks, it works perfectly
Dr. Frank Gaeth