It would be easy to settle in SQL. 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;
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;
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;
data want;
set have1 have2 ;
by id;
run;
Ksharp
... View more