Hello youngsh,
Here is a little example on how to do it:
Let's simulate some data to illustrate the program:
data T01_20091001
T01_20091002
T01_20091003;
do i=1 to 10000;
x=ranuni(0);
select;
when(mod(i,3)=0) output T01_20091001;
when(mod(i,3)=1) output T01_20091002;
when(mod(i,3)=2) output T01_20091003;
otherwise put "Never seen !";
end;
end;
run;
data T02_metadata;
to_import="T01_20091001"; output;
to_import="T01_20091002"; output;
run;
This macro will append the content of the file T01_date to T04_union. The date is added to the input file before the append takes place. This is done with a "view" (this doesn't require disk space)
%macro import_file_with_date(date);
proc sql;
create view T03_temp as
select input("&date",yymmdd8.) format=date9. as date, *
from T01_&date;
quit;
proc append data=T03_temp out=T04_union;
run;
proc sql;
drop view T03_temp;
quit;
%mend;
Let us invoke the macro "manually"
* import 1 file manually;
%import_file_with_date(20091001);
You can generate macro calls using a data step
* import multiple files from list in T02_metadata;
data _NULL_;
set T02_metadata;
call execute(cats('%import_File_with_date(',scan(to_import,2,"_"),');'));
run;
You could add some code in the macro to handle re-loads.
I hope this helps?
yoba
Message was edited by: yoba