10-19-2016 06:48 AM
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.
10-19-2016 07:11 AM
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?
10-19-2016 08:16 AM
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.
10-19-2016 11:03 AM - edited 10-19-2016 11:04 AM
@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.
10-19-2016 11:39 AM
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.
10-19-2016 04:31 PM