Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing strings with symbols from different alphabets

I want to compare two strings which contains symbols from different alphabets (e.g. Russian and English). I want that symbols which looks similarly is considered as equal to each other.

E.g. in the word "Mom" letter "o" is from English alphabet (code 043E in Unicode), and in the world "Mоm" letter "о" is from Russian alphabet (code 006F in Unicode). So ("Mom" = "Mоm") => false, but I want it would be true. Is there some standard SAS function or I should wright a macro to do it.

Thanks!

like image 637
PierreVanStulov Avatar asked Nov 09 '22 20:11

PierreVanStulov


1 Answers

I would do like that:

First I would make map. I mean which letter in Russian language corresponds to what letter in English language. Example:
б = b
в = v
...

I would store this map in a separate table or as macroVars. Then I would create a macro loop, with tranwrd function, which loops throug the map, which was created.

Example here could be like that.

data _null_;
    stringBefore = "без";
    stringAfter = tranwrd(stringBefore,"а","a");
    stringAfter = tranwrd(stringAfter,"б","b");
    stringAfter = tranwrd(stringAfter,"в","v");
...
run;

After this transformation I think You can compare your strings.

like image 193
K.I. Avatar answered Nov 14 '22 23:11

K.I.