dxystata 发表于 2014-11-24 23:31
运行后出错!
it seems that there is problem for this web editor.
string=prxchange('s/(\.*\=)(.*)/$1"$2"/i',-1,string);
need dollar symbole before 1 and 2.
data aaa;
input;
name=scan(_infile_,1,' ');
format=scan(_infile_,-1,' ');
cards;
sex 1=male|2=female
hy 1=married|2=unmarried
mz 1=han|2=minority
xy1 0=no|1=occasional|2=often
group 1=1+2|2=3
;
run;
data _null_;
set aaa end=last;
if _n_=1 then call execute(
'proc format;');
call execute('value ' ||strip(name)||"fmt");
do i=1 to count(format,'|')+1;
string=scan(format,i,'|');
_string=prxchange('s/(\.*\=)(.*)/$1"$2"/i',-1,string);
call execute(_string);
end;
call execute(';');
if last then call execute('; run;');
run;