Hi,
I have a dataset "TABLES" which contains 100 rows and only 1 variable "name_dataset".
Each row contains the name of another SAS dataset.
I want to write a procedure which
- reads those 100 rows one by one, (read the name of the SAS dataset)
- via a macro, reads each dataset (one by one), do some modifications, and append the results to a master table.
Seems easy, but I'm a little bit stuck here.
I thought that with the code below, it would do 100 iterations and at each iteration it would save the name of the dataset of the current iteration into a macrovariable and executes the macro that follows.(readOneFile). But what it does, it takes only the last value (row 100) and only executes 1 time the macro. So it's only 1 iteration if I understand well. Does anybody knows in what way I have to modify my code so that i actually does 100 times the same, but each time with another dataset/table?
This is the code I have so far:
%macro readAllFiles(table_master=);
... some code, which works well ...
data _null_;
set test.TABLES; /* TABLES contains 100 observations and only 1 field 'name_dataset' */
call symput ('name_dataset', name_dataset);
%readOneFile(lib=source,table_in=&name_dataset, table_out=temp_table)
PROC APPEND BASE=&table_master(compress=yes) DATA=temp_table force;
RUN;
%delete_table(table=temp_table);
run;
%mend;
%macro ReadOneFile (lib=,table_in=,table_out=);
... some code, which works well ...
%mend;
... View more