02-08-2016 11:41 PM
I have a Oracle table in which some columns are in Russian. I need to import the Oracle table in a SAS dataset and convert all these columns into English. What's the best way to go about this? Also what would be the encoding type. It would really help if you can let me know the exact syntax.
Some values are a mixture of English & Russian, so the code should work for those too.
02-09-2016 02:32 AM
SAS doesn't do language translations so you really have two basic choices. One is to use a translation app like Google Translate, the other is to send your data off to be translated by a company or person doing translation services.
Regarding the encoding, what does the Russian text look like when you import it now? Does it display correctly or not?
02-09-2016 03:17 AM
I do not think using Google translate is a good idea as there are thousands of strings in Russian.
After importing, the Russian text looks like "¿¿¿¿¿¿¿¿¿¿ ¿¿¿¿¿¿¿ ¿¿¿¿. ¿¿¿¿¿¿-¿¿-¿¿¿¿" (series of inverted question marks, often separated by space or dash). Different strings have different number of question marks/space/dash. Position of space and dash also vary. Is it possible to convert these to English using some intelligent SAS option?
02-09-2016 03:39 AM
OK so you have encoding issues. If you changed the encoding setup in SAS to display the Cyrilic characters correctly that is all SAS can do. It isn't going to translate Russian into English.
I'm not an expert in this area but this link might be helpful:
02-09-2016 06:10 AM
Thanks a lot!
Looks like encoding value for Cyrilic is wcyrillic.
Another problem is I'm trying to import the dataset from Oracle DB into SAS using the following syntax:
libname ... oracle user=... password='...' path=...; run;
How do I fit encoding="wcyrillic" option here?
Thanks again for your guidance.
02-09-2016 02:29 PM - edited 02-09-2016 02:34 PM
No problem. I've done a bit more searching and found this:
Also this SAS note explains how to query the Oracle encoding:
and this shows you how to set the NLS_LANG setting for Oracle:
02-15-2016 07:15 AM - edited 02-15-2016 07:42 AM
One weird thing is that the macro generates correct output only when it is run twice. First time, it generates incorrect characters, but second time, it generates correct values for the Russian characters! I replicated the occassions multiple times, restarted SAS and my computer itself, but the result remains same. Not that this is a roadblock, but was curious to know why SAS is behaving so strangely.
02-15-2016 10:58 AM
I didn't look at your particular macro, but that type if situation is usually caused by assigning a value to a macro variable within the macro without first defining its scope. So you run the macro and it creates some local macro variable that disappears when the macro ends. Later in your code you create some global macro variable with the same name. Then the second time you run it the macro will use the global macro variable and viola! you can see the results.
Need further help from the community? Please ask a new question.