标题: 求助:sas如何生成汉字的拼音? [打印本页] 作者: shiyiming 时间: 2012-5-28 23:12 标题: 求助:sas如何生成汉字的拼音? 求助:各位高手,我有一个姓名变量,是汉字的,我想把它生成拼音,用SAS能实现吗?
[code:2aicyzb5]
data a;
input x;
cards;
陈三
李四
王五
;
run;
[/code:2aicyzb5]
再生成一个Y变量,其值是变量x的拼音。该如何实现呢?作者: shiyiming 时间: 2012-5-29 01:42 标题: Re: 求助:sas如何生成汉字的拼音? You might need to create a look-up table that contains the mapping of each 汉字 with its 拼音.作者: shiyiming 时间: 2012-6-11 21:45 标题: Re: 求助:sas如何生成汉字的拼音? [code:o0t17726]
data a;
input x $;
u=substr(x,1,2);
v=substr(x,3,2);
ith=_n_;
cards;
陈三
李四
王五
;
run;
data uds;
set a;
keep ith u;
run;
data vds;
set a;
keep ith v;
run;
data b;
input char $ pinyin $;
cards;
陈 chen
三 san
李 li
四 si
王 wang
五 wu
;
proc sql noprint;
create table c as
select uds.ith, uds.u, b.pinyin
from uds,b
where uds.u=b.char;
quit;
proc sql noprint;
create table d as
select vds.ith, vds.v, b.pinyin
from vds,b
where vds.v=b.char;
quit;
proc sql noprint;
create table e as
select strip(c.u)||strip(d.v) as x,strip(c.pinyin)||strip(d.pinyin) as py
from c,d
where c.ith=d.ith;
quit;
[/code:o0t17726]
上述程序是非智能的,就是不能自动根据观测的大小匹配注音。
在测试智能程序时,遇到如下问题,请高手指点,我的想法是把变量的观测值,拆成一个一个的汉字,然后在字典中查找。查找程序已经写好,但是被卡在了自动拆分这个环节,
如下程序,shixing ba di yi ge ji fu zhi gei bian liang x1, dan shi mei you chneg gong