|
|
5#

楼主 |
发表于 2010-7-1 15:31:55
|
只看该作者
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;
options cmplib = work.func;
data a;
infile datalines dsd;
input @;
_infile_=quotation(_infile_,'|');
input (x y z w s t) ($);
datalines;
a'||3|'|'|9
c'|1||3|5|7
d'|7|8|8||4
;[/code:3ps3bd74] |
|