|
|
Re: 怎样从中文姓名提取首字母
依照大牛的逻辑:
[code:3awm9j67]
data chin ;
input name $20. ;
cards;
阿三
欧阳仔仔
小明
;
run;
%macro a();
shouxie='a';
if zi>='八 ' then shouxie='b ';
if zi>='才 ' then shouxie='c ';
if zi>='大 ' then shouxie='d ';
if zi>='额 ' then shouxie='e ';
if zi>='发 ' then shouxie='f ';
if zi>='嘎 ' then shouxie='g ';
if zi>='哈 ' then shouxie='h ';
if zi>='及 ' then shouxie='j ';
if zi>='卡 ' then shouxie='k ';
if zi>='拉 ' then shouxie='l ';
if zi>='马 ' then shouxie='m ';
if zi>='那 ' then shouxie='n ';
if zi>='哦 ' then shouxie='o ';
if zi>='怕 ' then shouxie='p ';
if zi>='其 ' then shouxie='q ';
if zi>='热 ' then shouxie='r ';
if zi>='萨 ' then shouxie='s ';
if zi>='他 ' then shouxie='t ';
if zi>='哇 ' then shouxie='w ';
if zi>='西 ' then shouxie='x ';
if zi>='呀 ' then shouxie='y ';
if zi>='咋 ' then shouxie='z ';
eng=compress(eng||shouxie);
i=i+2;
%mend a;
data eng;
set chin;
length eng $4;
eng="";
i=1;
zi=substr(name,i,2);
do while(compress(zi)~="");
%a;
zi=substr(name,i,2);
end;
keep name eng;
run;
[/code:3awm9j67] |
|