I'd first see if there was a way to adjust the process that creates all of these separate tables in order to avoid that. If that's not possible, try something like this:
*Data setup to replicate the datasets you should have;
data _null_;
start_dt='01JAN1990'd;
end_dt='01DEC2016'd;
dt=start_dt;
i=0;
do until(dt>end_dt);
curr_dt=put(dt, monyy7.);
call execute(catx('', 'data', curr_dt, ';message = "Hi from', curr_dt,
'";run;') );
call execute(catx('', 'data', cats('est', curr_dt),
';message2 = "Hi from estimate:', curr_dt, '";run;') );
i+1;
dt=intnx('month', start_dt, i, 'b');
end;
run;
*Get table names -- you may have to adjust WORK to MYFILES;
proc sql;
create table _tabs as select memname as table_name from dictionary.tables
where libname='WORK' and lengthn(memname)=7 order by input(memname, monyy7.);
quit;
/***
Read through table names and execute code that looks like:
data wantJAN1990;
merge JAN1990(in=a) estJAN1990(in=b);
if b;
run;
***/
data _null_;
set _tabs;
call execute(catx('',
'data',cats('want', table_name),
'; merge',cats(table_name, '(in=a)'), cats('est', table_name, '(in=b)'),
'; if a; run;'
));
run;
*Combine all want datasets together;
data final_want;
set want:;
run;
*Preview results;
proc print data=final_want(obs=20);
run;
... View more