data mylib.test(keep = cxmc ouchar);
set mylib.cxmc;
cxmc=compress(cxmc,' -_()');
i=1;
array ch(30) $1.;
do while(i<=30);
ch(i)=substr(cxmc,i,1);
if rank(ch(i)) < 161 then
ch(i)="";
i=i+1;
end;
ouchar=ch(1)||ch(2)||ch(3)||ch(4)||ch(5)||ch(6)||ch(7)||ch(8)||ch(9)||ch(10)||
ch(11)||ch(12)||ch(13)||ch(14)||ch(15)||ch(16)||ch(17)||ch(18)||ch(19)||ch(20)||
ch(21)||ch(22)||ch(23)||ch(24)||ch(25)||ch(26)||ch(27)||ch(28)||ch(29)||ch(30);
ouchar=compress(ouchar);
run;作者: shiyiming 时间: 2009-8-26 21:07 标题: Re: 选取某字段中文字符,使用循环的问题 data mylib.test(keep = cxmc ouchar);
set mylib.cxmc;
cxmc=compress(cxmc,' -_()');
if _n_=1 then ouchar=substrn(cxmc,1,0);*保证ouchar有足够的长度而且初始值为空;
do i=1 to length(cxmc);
if rank(substrn(cxmc,i,1))<161 then ouchar=compress(ouchar||substrn(cxmc,i,1));
end;
run;