谢谢楼上两位,我刚发完这个帖子就琢磨出来了。
%macro doit(memname);
proc sql;
create table want.&memname as
select YEAR,
sum(SALE*anyalpha(first(ID))) as SALE1,
sum(SALE) as TOTALSALE,
from have.&memname
group by YEAR;
quit;
%mend doit;
data _null_;
set work.member; /* this is a list I created before hand, it contains all the member name of the datasets I have*/
call execute('%doit('!!memname!!');');
run;这是我的代码。可能最后不太准确,不过反正得到我想要的了。谢谢大家