Ok, this one fixes multi byte problem.
data have;
input string_1 : $12. string_2 $12.;
datalines;
elbow below
brog grob
yet tey
abc efg
xxxxx xxxx
żółć ćółż
空手道 道手空
;
run;
data x;
length string_1 string_2 $ 12;
x="空";
string_1=x;
string_2=char(x,1)!!char(x,3)!!char(x,2);
drop x;
run;
data have2;
set have x;
run;
proc print;
run;
%let n=10; /* max number of letters */
data want;
set have2;
array str1_[&N.] $ 4. _temporary_;
array str2_[&N.] $ 4. _temporary_;
l1 = klength(string_1);
l2 = klength(string_2);
anagram=0;
if l1 NE l2 then
do;
output;
if 0;
end;
do i = 1 to l1;
str1_[i] = ksubstr(string_1,i,1);
str2_[i] = ksubstr(string_2,i,1);
end;
call sortc(of str1_[*]);
call sortc(of str2_[*]);
anagram = (cats(of str1_[*]) = cats(of str2_[*]));
output;
run;
proc print;
run;
Bart
... View more