Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Difficulty with dates

737 views
Skip to first unread message

Philip Feeley

unread,
Jul 17, 2003, 2:35:35 PM7/17/03
to
When importing data from an Excel file, SPSS doesn't seem to handle
dates very well. I've found that the dates do not transfer correctly
(or not at all) with recent versions of Excel. The only one I've been
able to get to work consistently is Excel v. 3.0. But lately even this
has been failing. This could be because the original data file has the
dates formatting differently (i.e. mm-dd-yyyy and mm/dd/yyyy). I guess
I'll need to get that consistent before I worry about importing the file.

When I import the file the date fields are formatted as strings. If I
try to change this to date all the data disappears. Obviously, I'm doing
something wrong...

Thanks for any help.

Phil

Rick Oliver

unread,
Jul 17, 2003, 3:53:29 PM7/17/03
to
As long as all the values in the same column are recognized as some kind of
legitimate date format in Excel, then SPSS should read them as dates. I
think by default SPSS will display these dates in dd-mm-yyyy form, but the
original dates in Excel don't have to be in that form -- they just have to
be in a format that Excel recognizes as a date. If, however, anything in the
column is not a date, then SPSS will read the variable in string format.

"Philip Feeley" <phi...@interchange.ubc.ca> wrote in message
news:bf6q9n$tc$1...@nntp.itservices.ubc.ca...

Bruce Weaver

unread,
Jul 17, 2003, 5:33:21 PM7/17/03
to

This won't likely help for your present situation. But in
future, you might want to ask the folks you're working with
to enter dates as 3 numeric variables in separate columns
(Day, Month, and Year). This makes importing into SPSS
problem-free, and you can easily convert the 3 numeric
variables to a DATE variable in SPSS, like this:

compute datevar = date.dmy(day,month,year).
exe.

Cheers,
Bruce
--
Bruce Weaver
wea...@mcmaster.ca
www.angelfire.com/wv/bwhomedir/

Fred

unread,
Jul 18, 2003, 5:17:51 AM7/18/03
to
If you import the date as a text variable, rather than as a date
variable, you can run
comp date=date.dmy(number(substr(datestr,4,2),f2),number(substr(datestr,1,2),f2),number(substr(datestr,7,4),f4)).
format date (date11).
where datestr is the date in text format.


which should get you the date you want, in the format of dd-mmm-yyyy.

Bruce Weaver <wea...@mcmaster.ca> wrote in message news:<bf74or$2ps$1...@informer1.cis.mcmaster.ca>...

0 new messages