BookmarkSubscribeRSS Feed
sbunny364
Fluorite | Level 6

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

4 REPLIES 4
Reeza
Super User

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. 

sbunny364
Fluorite | Level 6
I have converted .xlsx to .xls

Will try as per your suggestion

Thanks much
Reeza
Super User

@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.

sbunny364
Fluorite | Level 6

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 526 views
  • 1 like
  • 2 in conversation