Here is a convenient way if you only need to SET them together. proc sql; create table want as select * from old outer union corr select * from new ; quit; And If you only want to change the length of variables : data have1;
input name : $2. x $ id;
cards;
NB sds 1
RN sdft 1
;
run;
data have2;
input name $ x : $14. id;
cards;
NB sdsfsddfs 2
RN sdsdfsdfsder 3
BOTH sdsds 4
;
run;
/*First,we get the max length of variables in every tables */
proc sql;
create table temp as
select memname,name,max(length) as max_len
from dictionary.columns
where libname='WORK' and memname like 'HAVE%' and type='char'
group by name
order by memname,name;
quit;
/* then we use sql to change the variable's length fastly and easily.
we need to generate the sql code like:
proc sql;
alter table have1
modify name char(8),x char(14);
alter table have2
modify name char(8),x char(14);
.........
quit;
*/
data _null_;
set temp end=last;
by memname;
if _n_ eq 1 then call execute('proc sql;');
if first.memname then call execute('alter table '||memname||' modify ');
call execute(name||' char('||put(max_len,8.)||')');
if not last.memname then call execute(',');
else call execute(';');
if last then call execute('quit;');
run;
/*finally, get what we want */
data want;
set have1 have2 ;
run;
Xia Keshan
... View more