- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could try scantext= option in proc import .