Hi
A similar approach but without the need to re-write the table.
data a;
attrib
key label='this is the key & nothing else'
a format=8. label='test & test';
do key=1 to 5;
a=1;
b='abc';
c=1;
output;
end;
run;
data b;
do key=6 to 10;
a=1;
b='abcd';
d=5;
output;
end;
run;
%let rename=;
%let assign=;
%let length=;
%let drop=;
proc sql noprint;
select
cats(BASE.name,'=xyz_',BASE.varnum)
,cats(BASE.name,'=xyz_',BASE.varnum,';')
,case
when BASE.type='char' then
catx(' ',BASE.name,cats('length=$',BASE.length))
else catx(' ',BASE.name,cats('length=',BASE.length))
end
,cats('drop xyz_',BASE.varnum,';')
into :rename separated by ' '
, :assign separated by ' '
, :length separated by ' '
, :drop separated by ' '
from dictionary.columns BASE, dictionary.columns DATA
where upcase(BASE.name)=upcase(DATA.name)
and base.length ne data.length
and BASE.libname='WORK' and BASE.memname='A'
and DATA.libname='WORK' and DATA.memname='B'
order by BASE.varnum
;
quit;
%put rename: &rename;
%put assign: &assign;
%put length: &length;
%put drop: &drop;
data V_B / view=V_B;
set B(rename=(&rename));
attrib &length;
&assign
&drop
run;
proc append base=A data=V_B force nowarn;
quit;