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);
run;
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
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. https://support.microsoft.com/en-us/kb/214261/
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.
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?
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
You could try scantext= option in proc import .
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.