excel 2016 time field to sas

Reply
Occasional Contributor
Posts: 5

excel 2016 time field to sas

experts,

 

here is my time variable looks like

 

8:42:00

13:07:00

12:30:00


i am importing the excel file and converting to sas datasets using proc import and some how sas is displaying as 30DEC1899 in most of the observations and few other dates. 

 

here is my code

 

proc import datafile="location."
out=outlocation
dbms=excel replace;

getnames=yes;
mixed=no;
scantext=yes;
usedate=yes;
scantime=yes;
quit;

 

i want to read the excel file time variable into sas exactly as i pasted above and the file is .xls format (2016 excel).

 

thank you

sunny

Grand Advisor
Posts: 17,325

Re: excel 2016 time field to sas

Did Excel revert back to XLS in 2016? 

 

 

Try removing the Usedate option unless you need it. Ensure the variable has the correct format in SAS - proc import guesses - and not always correctly. 

A SAS time is number of seconds, so without a format it should appear as an integer. 

Occasional Contributor
Posts: 5

Re: excel 2016 time field to sas

I have converted .xlsx to .xls

Will try as per your suggestion

Thanks much
Grand Advisor
Posts: 17,325

Re: excel 2016 time field to sas


sbunny364 wrote:
I have converted .xlsx to .xls

Will try as per your suggestion

Thanks much

Why? Try the XLSX file using DBMS=XLSX

 

If the file is XLS its Excel 95-ish not Excel 2016.

Occasional Contributor
Posts: 5

Re: excel 2016 time field to sas

it looks like in the excel ...one of the values is being entered as date and the rest are time ...so SAS is reading all the values  as date ...just figured it...

 

thank you reeza

Ask a Question
Discussion stats
  • 4 replies
  • 165 views
  • 1 like
  • 2 in conversation