data aaa;
label x="编号" z="值";
format sex sexfmt.;
format time mmddyy10.;
input z y$ x sex time@@;
cards;
1 a 2 1 2000
1 b 3 2 1000
2 c 4 1 3000
;
run;
data test;
set sashelp.vcolumn;
where libname="WORK" and memname="AAA";
length code $100;
if type="num" then do;
if missing(format) then code=cat(strip(name),"=put(",strip(name)||"_1",",best.-l);");
else code=cat(strip(name),"=put(",strip(name)||"_1,",strip(format)||"-l);");
end;
else if type="char" then code= cat(strip(name),"=",strip(name)||"_1;");
run;
proc sql noprint;
select strip(name),
strip(name)||"="||quote(strip(label)||" "),
strip(name)||"="||strip(name)||"_1" ,
strip(code)
into : name separated by " ",
: label separated by " ",
: rename separated by " ",
: code separated by ""
from test;
quit;
data transform;
label &label;
set aaa(rename=(&rename));
&code
keep &name;
run;