Date: Wed, 1 Sep 2004 11:12:42 -0700
Reply-To: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Choate, Paul@DDS" <pchoate@DDS.CA.GOV>
Subject: Re: Importing Excel Dates in V9 and V8
Hi Steve -
In SAS9 you need USEDATE=NO; to get dates as datetime. The default must be
YES.
PROC IMPORT OUT= WORK.DATES
DATAFILE= "dates.xls"
DBMS=EXCEL REPLACE;
SHEET="dates$";
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=NO; **<<<dates as datetime;
SCANTIME=YES;
RUN;
As an aside, you could test your values to see which they are - datetimes
will be multiples of 86400 plus the number of seconds for the timepart.
Unless you have datetimes from 12/31/59-1/1/60 the numeric values behind
your datetimes will always be much larger in absolute value than dates.
A test like
If mod(date,86400)=0 then date=datepart(date);
will convert your datetimes to dates.
Good luck
Paul Choate
DDS Data Extraction
(916) 654-2160
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Steve
James
Sent: Monday, August 30, 2004 9:50 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Importing Excel Dates in V9 and V8
There appears to be a difference in the way SAS V8.2 and V9 converts
Excel spreadsheet data using PROC IMPORT. For dates, they are
converted to a SAS datetime value in V8.2 but in V9 they are converted
as SAS dates (this is on Windows).
I have an application that is used by one person using V8 and everyone
else using V9. Of course I could just install 9 on the one's computer
but I'm wondering if there's a different way. I've not seen anything
about this in SAS-L or anywhere else. It seems odd/unfortunate that
SAS would change the behavior of a procedure like that, but it appears
that they have.
Of course I could check the version number and then use a data step to
convert the datetime values to date values, but is there a simpler
way?
TIA,
Steve James
Centers for Disease Control and Prevention
sjames@cdc.gov