DATA Step, Macro, Functions and more

Not able to read chinese characters

Posts: 65

Not able to read chinese characters



I am trying to import the data from excel file to data set using below code:-

options locale=zh_CN; 
    PROC IMPORT OUT= work.translate_title_footnotes
                DATAFILE= "/opt/standards/test/test.xls"
                DBMS=xls REPLACE;


But the chinese characters are not getting read and writtent properly due to the encoding problem. I am able to change the encoding locally in my configuration file and it works fine but when i remote submit the code, the data gets distorted.Also, I can't change the encoding of SAS on the server since it might cause problems to other users working on it.


 Attached is the excel file from which I am reading the data. Please help me with the solution.

Super User
Posts: 5,257

Re: Not able to read chinese characters

What is your encoding setting. You probably need to define a double byte, like UTF-8.

Can you see what encoding is used in the Excel file?

Data never sleeps
Super Contributor
Posts: 408

Re: Not able to read chinese characters

If your SAS server cannot be changed to UTF-8 (which is more than likely what you need) you may introduce a second SAS server living alongside it. This assumes a datamanagement basic or advanced configuration where you have a logical server context (by default named SASApp) in the metadata. If that's the case (again, I am assuming), create another server context using deployment wizard, e.g. appropriately named SASUTF, that starts SAS unicode server processes. This way you can choose to use that server where othwers can continue to use their Latin servers as usual.


Your code attempts to set the encoding by using the LOCALE option. This is however not enough. locale is about language / culture dependend presentation of dates, numbers etc. It will not affect the session encoding. This can only be done at SAS invocation time. There is a SAS NLS homepage in the support site for lots of detail.


If you do not have the setup as I suggested you can always start a SAS session by using the appropriate start script in the SASROOT/bin/ directory. Look for something like sas_u8 or sas_dbcs.


This is all in ignorance about your the details of your technical environment (O/S, SAS client, licensed products). Please elaborate on this if you want to have more guidance.


- Jan.

Posts: 65

Re: Not able to read chinese characters

[ Edited ]

@jklaverstijn: I have these statements to invoke sas in my tcpunix.scr file:

type 'sas -dmr -comamid tcp -device 
       -noterminal -nosyntaxcheck' LF;

Also, I am using SAS 9.3 installed on the unix server. How should I invoke SAS with dbcs support using the above statement. Is it feasible this way? Please enlighten.

Super User
Super User
Posts: 6,500

Re: Not able to read chinese characters

I don't think that you can use SAS/Connect to connect sessions that use different encodings.


But you could try adding the -encoding setting to the command that starts SAS.  or add a -config setting that points to a system level SAS config file that your SAS administrator has setup to launch SAS using UTF-8 encoding.

Occasional Contributor
Posts: 11

Re: Not able to read chinese characters

We are also working with Chinese characters and it is definitely trial and error.  I've attached a document that we used ... maybe it will help you. 

Good luck!

Super User
Posts: 9,681

Re: Not able to read chinese characters

XLS engine is not support for Chinese/Japanese character.

Try XLSX or EXCEL engine:







Ask a Question
Discussion stats
  • 6 replies
  • 6 in conversation