I am trying to pull data from 17 datasets, data2001, data2002, ...data2017 (one for each year from 2001 to 2017). I also need to run a proc sql procedure to each dataset. Can anyone tell me what is wrong with my code please? Many thanks! %macro pull_data; %do i = 2001 %to 2017; data tmp&i; set raw.data&i; run; proc sql; create table temp&i as select unique redcode, year(date) as year, qtr(date) as qtr, mean(price) as avr_price, count(price) as n from tmp&i group by redcode, year, qtr; quit; %end; %mend pull_data; data full; set temp2001 - temp2017; run;
... View more