BookmarkSubscribeRSS Feed
Aditi24
Obsidian | Level 7

Hi,

 

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;
         sheet="title_footnotes";
         getnames=yes;
    RUN;

	

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.

6 REPLIES 6
LinusH
Tourmaline | Level 20

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
jklaverstijn
Rhodochrosite | Level 12

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.

Aditi24
Obsidian | Level 7

@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.

Tom
Super User Tom
Super User

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.

acairns
Fluorite | Level 6

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!

Ksharp
Super User

XLS engine is not support for Chinese/Japanese character.

Try XLSX or EXCEL engine:

 

dbms=excel 

 

or

 

dbms=xlsx

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 6 replies
  • 5630 views
  • 0 likes
  • 6 in conversation