I have improve my solution, it is a user-defined function now! This function named "anyhan", you can use it like "anynum" or "anyalpha", to search for the first Chinese character(Basic set: U+4E00-9FA5).
proc fcmp outlib=work.funcs.char;
%*Find the first Chinese character(Basic set: U+4E00-9FA5);
function anyhan(string$);
klen=klength(string);
rst=0;
do i=1 to klen until(rst^=0);
kchar=ksubstr(string,i,1);
if length(kchar)>1 then do;
if '\u4E00'<=unicodec(kchar)<='\u9F5A' then rst=find(string,kchar,'t');
end;
end;
return(rst);
endfunc;
run;
data have;
input text $42.;
cards;
42anyhan
42任何汉字
42any汉字
42 +_@#$汉字
42龼龽龾龿鿀鿁汉字
أي كانجي
テストします
Путин
;
run;
option cmplib=work.funcs;
data want;
set have;
han_pos=anyhan(text);
run;
The result looks like:
Note: The result value indicates the position of the first Chinese character in source string, however, it will be effected by the encoding of SAS session.
... View more