BookmarkSubscribeRSS Feed
Quartz | Level 8

Hi all,

I've been trying to import an TEST.XLSX file using below code:


libname samp excel "TEST.XLSX" dbMax_text=32767 stringdates=YES scan_timetype=YES;

data work.Data_Step;

set samp."CSR$"n

(dbSasType= (ext_notes='CHAR(32767)') dbmax_text=32767);


libname samp clear;


Despite setting the maximum lengths, I found that the field ext_notes is still truncated, but the length of the column is maximum.

When I use SAS EG Import Wizard to import the said excel file, the field ext_notes is not truncated. Perhaps there is a hidden special character here which causes the truncation?cia

Diamond | Level 26 RW9
Diamond | Level 26

Whilst Excel can have 32767 characters per cell, I believe SAS is limited to how many characters per column.  I would suggest you do a text to columns in Excel and split the data up.  Then export to CSV and write a datastep import to ensure you get what you want.

Quartz | Level 8

Hi RW9,

Thank you for the response.

SAS produced one cell of the affected field at just 200 characters as displayed in the table.

However, that cell is actually just 1000 characters. The cell has already been truncated even though it hasn't reached the maximum SAS length.

Diamond | Level 26 RW9
Diamond | Level 26

Yes, another delightful artifact of working with Excel.  As I always suggest, best method is to save as CSV, then write a datastep to read the data in.  Excel is not a data transport tool and there a numerous issues with using it.  Personally I wasn't that impressed with the libname statement, not because of the tech, but just the interaction between a structured format software and an unstructured file format such as Excel.  You wouldn't for instance enter data into Word and then try to read that in would you?

Super User

Don't be too optimistic. I've had users who stored their SAS programs as .doc.

"There are only two infinite things, the universe and human stupidity. And I'm not so sure about the universe."

Albert Einstein

Super User

You could try scantext= option in proc import .

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 4 in conversation