DATA Step, Macro, Functions and more

Coverting Russian text to English

Accepted Solution Solved
Reply
Contributor
Posts: 35
Accepted Solution

Coverting Russian text to English

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.


Accepted Solutions
Solution
‎02-15-2016 07:12 AM
Super User
Posts: 3,254

Re: Coverting Russian text to English

Posted in reply to abhik_giri

Cool! I saw the macro in the link to the paper.You've now taught me how to do it too. That is the beauty of the SAS Community.

 

Please mark the post as answered. 

 

View solution in original post


All Replies
Super User
Posts: 3,254

Re: Coverting Russian text to English

Posted in reply to abhik_giri

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? 

Contributor
Posts: 35

Re: Coverting Russian text to English

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?

 

Super User
Posts: 3,254

Re: Coverting Russian text to English

Posted in reply to abhik_giri

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:

 

http://support.sas.com/documentation/cdl/en/nlsref/67964/HTML/default/viewer.htm#n1d2i07lune0dxn1bsa...

 

 

Contributor
Posts: 35

Re: Coverting Russian text to English

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.

Super User
Posts: 3,254

Re: Coverting Russian text to English

[ Edited ]
Posted in reply to abhik_giri

No problem. I've done a bit more searching and found this:

 

http://support.sas.com/resources/papers/Multilingual_Computing_with_SAS_94.pdf

 

Also this SAS note explains how to query the Oracle encoding:

 

http://support.sas.com/kb/51/411.html

 

and this shows you how to set the NLS_LANG setting for Oracle:

 

http://support.sas.com/kb/18/688.html

Contributor
Posts: 35

Re: Coverting Russian text to English

[ Edited ]

 

In one of the links you provided, there was a macro which effortlessly did my job! 

Solution
‎02-15-2016 07:12 AM
Super User
Posts: 3,254

Re: Coverting Russian text to English

Posted in reply to abhik_giri

Cool! I saw the macro in the link to the paper.You've now taught me how to do it too. That is the beauty of the SAS Community.

 

Please mark the post as answered. 

 

Contributor
Posts: 35

Re: Coverting Russian text to English

[ Edited ]

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.

Super User
Super User
Posts: 7,054

Re: Coverting Russian text to English

Posted in reply to abhik_giri

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 511 views
  • 1 like
  • 3 in conversation