BookmarkSubscribeRSS Feed
Jack2012
Obsidian | Level 7

Dear All, 

 

Just facing a terrible issue when I try to reading from an simple external Excel file, and found there is Warning(figure1) and the problomatic result(figure2). 

 

The sas session is EUC-CN, I am hunting for the solution, please let me know if you have, and I would be highly appreciated. 

 

 

SAS CODE:

filename x "D:\sas code\encodingIssue\test.xlsx" encoding="utf-8";


proc import datafile=x out=test dbms=xlsx replace;getnames=yes;run;

Jack2012_0-1683253024537.pngJack2012_1-1683253038660.png

 

 

 

 

 

 

5 REPLIES 5
SASKiwi
PROC Star

I suggest you try the XLSX and EXCEL LIBNAMEs and see what your spreadsheet looks like in VIEWTABLE:

libname x XLSX "D:\sas code\encodingIssue\test.xlsx" encoding="utf-8";

libname x EXCEL "D:\sas code\encodingIssue\test.xlsx" encoding="utf-8";
Jack2012
Obsidian | Level 7
ERROR: Libref X is not assigned. ERROR: Error in the LIBNAME statement. ERROR 22-7: Invalid option name ENCODING. Thank you, but both snippet have above error.
ballardw
Super User

See if UTF-16 helps.

 

Note: search this forum for Excel and Import data problems.

If you are likely to have more than one file with the same data structure in the long run saving XLSX to a CSV format and reading that with a data step is much more consistent.

SASKiwi
PROC Star

Did you try without the ENCODING option? If not please try without that.

RD2
Fluorite | Level 6 RD2
Fluorite | Level 6

You need using SAS (Unicode Support) to run your code. 

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
  • 387 views
  • 0 likes
  • 4 in conversation