SAS中文论坛

标题: 求助: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

[code:o0t17726]

%let ch=陈三;
data m;
x1=substr(&ch,1,2);
run;

[/code:o0t17726]
作者: shiyiming    时间: 2012-6-12 09:15
标题: Re: 求助:sas如何生成汉字的拼音?
简单:[code:2auy0j2f]x1=substr("&ch",1,2);[/code:2auy0j2f]
作者: shiyiming    时间: 2012-8-8 11:42
标题: Re: 求助:sas如何生成汉字的拼音?
<!-- l --><a class="postlink-local" href="http://www.mysas.net/forum/viewtopic.php?f=4&amp;t=6052&amp;p=20502&amp;hilit=%E6%B1%89%E5%AD%97+%E6%8B%BC%E9%9F%B3#p20502">viewtopic.php?f=4&amp;t=6052&amp;p=20502&amp;hilit=%E6%B1%89%E5%AD%97+%E6%8B%BC%E9%9F%B3#p20502</a><!-- l -->

This may help




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2