[code:2du1pdxk]data a;
infile datalines ;
input xx $20.;
array yy(6) $ x y z w s t;
do i= 1 to 6;
yy[i]=scan(xx,i,'|','m');
end;
drop xx i;
datalines;
a'||3|'|'|9
c'|1||3|5|7
d'|7|8|8||4
;
run;
proc print;
run;[/code:2du1pdxk]作者: shiyiming 时间: 2010-7-1 15:31 标题: Re: 请教一个关于特殊字符的难题!? 还有点小担心,有风险 9.2有效
[code:3ps3bd74]proc fcmp outlib=work.func.quot;
function quotation(in_str $,in_dlm $) $ 1024;
outargs in_str;
attrib sub_str length=$1024
out_str length=$1024
chr length=$1;
in_str=cats(in_str,in_dlm);
do i=1 to length(in_str);
chr=substr(in_str,i,1);
if chr in("'",'"') then flag=1;
if chr=in_dlm then
do;
if flag=1 then sub_str=quote(strip(sub_str));
out_str=strip(out_str)||','||strip(sub_str);
sub_str='';
flag=0;
end;
else sub_str=cats(sub_str,chr);
end;
return(substr(out_str,2));
endsub;
run;