You didn't provide the data and macro code, that's why I'm doing some assumptions:
/* assuming this is your data */
data have;
do subject=1 to 3;
do test=1 to 5;
do value=1 to sum(subject+test);
output;
end;
end;
end;
run;
/* and assuming this (looking at name) is your macro */
%macro get_sum(indata=have, subset=1, result=want);
proc sql;
create table &result. as
select
subject, test, sum(value) as sumof_value
from
&indata.
where
(&subset.)
;
quit;
%mend get_sum;
Having those I guess you want to do something like:
data _null_;
do i=1 to 3;
do j=1 to 5;
call execute(
'%nrstr(%get_sum(indata=have,' !!
catx(" ",'subset=subject eq ', i, 'and test eq ', j, ',') !!
'result=want_'!!catx("_",i,j) !!
'))'
);
end;
end;
run;
But! As @PaigeMiller already mentioned (and I 100% agree) it would be much wiser to use "by group processing".
In case SQL it would be something like this:
proc sql;
create table want as
select
subject, test, sum(value) as sumof_value
from
have
GROUP BY
subject, test
;
quit;
with GROUP BY clause. And for statistical procedures something like BY clause, or CLASS clause (if there is one).
Bart
... View more