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.
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?
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.
@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.
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.
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!
XLS engine is not support for Chinese/Japanese character.
Try XLSX or EXCEL engine:
dbms=excel
or
dbms=xlsx
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: