BookmarkSubscribeRSS Feed
parmesh
Calcite | Level 5

I am unable to read chinese characters from my source file. I will not be sharing the source file coz its has customer details. 

 

I have used the below code for importing.

 

 

libname sample xlsx "C:\MBR\property.xlsx";

data Sheetnames;
set sashelp.vtable;
where libname = 'SAMPLE';
run;

libname SAMPLE clear;

 

 

proc sql ;
select count(*)
into :NObs
from Sheetnames;
select compress(memname,'$')
into :Name1-:Name%left(&NObs)
from Sheetnames;
select compress(memname,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','K') AS CNAME
into :data1-:data%left(&nobs)
FROM Sheetnames;
quit;

 


%macro import;
%do i=1 %to &NObs;
proc import datafile="C:\MBR\property.xlsx "
out= &&data&i
dbms=xlsx replace;
sheet="&&name&i";
getnames=no;
datarow=6;
run;
%end;
%mend;
%import;

 

 

 

It would be very helpful if someone has the solution.

12 REPLIES 12
Ksharp
Super User

What is your SAS encoding ? if it was UTF-8 or EUN_CN ,should be OK.

 

proc options option=encoding value;
run;
parmesh
Calcite | Level 5
UAT-8
Ksharp
Super User

An workaround way is save your excel as a CSV file .

and import it again.

 

filename x 'c:\property.xlsx ' encoding='utf-8';

proc import ........

parmesh
Calcite | Level 5
But ll have to do this for 50 files.
Ksharp
Super User

There are many VBS in internet to convert excel to csv , google it you will find (  Excel2Csv.bat  ) .

Ksharp
Super User

And could you change your sas encoding as  euc-cn  

Ksharp
Super User

Also try these options.

libname x xlsx 'c:\temp\x.xlsx' inencoding='utf-8' outencoding='utf-8';
parmesh
Calcite | Level 5
Ok will try those and get back to you thank you for your time.
parmesh
Calcite | Level 5

I got this error in the log after running the below code that was shared yesterday.

 

 

24 libname x xlsx 'C:\MBR\property.xlsx' inencoding='utf-8' outencoding='utf-8';
_______
278
WARNING 278-63: The option INENCODING is not implemented in the XLSX engine.

 

 

NOTE: Libref X was successfully assigned as follows:
Engine: XLSX
Physical Name: C:\MBR\property.xlsx
WARNING 278-63: The option OUTENCODING is not implemented in the XLSX engine.

 

 

parmesh
Calcite | Level 5

Can anyone help on this please.

andreas_lds
Jade | Level 19
Interesting problem, afaik xlsx-files are stored in something fancy like utf-16 or even utf-32 - this was the case when I extracted an excel-file some time ago. The best solution starts with getting rid of excel as data source at all, because sooner or later you will run into other problems. But this has been recommended in the community so many times,that I stopped counting. You could, of course, open a track with tech-support, maybe theyhave a better idea.
parmesh
Calcite | Level 5
Ok thanks a lot for your advice.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 12 replies
  • 4499 views
  • 0 likes
  • 3 in conversation