Hi all, I've got a macro which loops through several datasets, filters the data based on a random selection of customers (previously generated) and removes all the columns of data I'm not interested in. This macro wasn't created by me, but the SQL code within was. %macro loop(start_month=201604, stop_month=201605); %local month; %do month=&start_month %to &stop_month; %put Month: &month; PROC SQL; Create table SampleData_&month as SELECT (Bits that I want to keep) FROM (Dataset)_&month AS V1 RIGHT JOIN Rand_Cust AS R ON R.AcctNum=V1.AcctNum; QUIT; %* SPECIAL CASE WHEN WE REACH END OF A YEAR; %if %substr(&month, 5, 2) = 12 %then %let month = %eval(&month + 88); %end; %mend loop; In the macro, Rand_Cust is the list of customer account numbers I generated in a previous step. The datasets that I'm pulling my data from follow the naming convention TABLENAME_YYYYMM, where TABLENAME is identical for all the sets and YYYYMM increments as you'd expect. Once all this data has been pulled, I'd like to append all the generated tables together, so that I can then sort by the account number (labelled AcctNum in the tables) and do some analysis. Whilst I could solve this issue with a number of APPEND steps, I'd like to know if there's a way I can either append during the loop, or if there's a command that can append all of the tables generated in a single step, as this would save me from having to use a long list of appends. The tables I'm taking my data from are monthly tables starting from 201606 and going up to 201805. Thanks for any help that can be offered.
... View more