DABUSHAN 发表于 2013-10-21 14:44 
谢谢@wwang111
里面还有个问题就是 字段有数值型的也有字符型的 不全都是字符定义的了
会不会复杂了 ...
proc sql;
create table test1 as
select name,type, max(length) as len
from dictionary.columns
where libname='WORK' and memname eqt 'W'
group by 1,2
;
quit;
data _null_;
set test1 end=last;
length code $ 1000;
retain code;
if _n_=1 then do;
if type=:'c' then code='data w0;length '!!strip(name)!!' $'!!strip(put(len,best.));
else code='data w0;length '!!strip(name)!!' '!!strip(put(len,best.));
end;
else do;
if type=:'c' then code=trim(code)!!''!!strip(name)!!' $'!!strip(put(len,best.));
else code=trim(code)!!''!!strip(name)!!' '!!strip(put(len,best.));;
end;
if last then do;
code=trim(code)!!'; run;';
call execute(code);
end;
run;