I'm not sure I understand what you are looking for. The following is based on the understanding that the data desribes the years and channels, but a where statement is the only thing that describes the desired 'types' you want to include.
If that is correct, then I'd suggest including the where statement as a macro variable and using it to build a file that contains all of the possible permutations.
For example:
proc format;
value $ channellbl
'A'='First'
'B'='Second'
'C'='Third';
run;
data loan_all;
input year (channel type) ($1.) numloans;
cards;
1 A1 100
2 B1 5
3 C1 23
4 A2 7
5 B2 10
;
%let where='1','2','3';
proc sort data=loan_all (keep=year) nodupkey out=allcombos1;
by year;
run;
proc sort data=loan_all (keep=channel) nodupkey out=allcombos2;
by channel;
run;
data allcombos3 (drop=_:);
length type $1;
_want=compress("&where.","'");
_i=1;
do while (scan(_want,_i) NE "");
type=put(scan(_want,_i),$1.);
_i+1;
output;
end;
run;
proc sql;
create table selectlevels as
select *
from Allcombos1,Allcombos2,Allcombos3
;
quit;
proc summary data=loan_all completetypes missing nway
classdata=selectlevels;
class year channel type;
var numloans;
output out=test sum=;
format channel $channellbl.;
where type in (&where.);
run;
data test;
set test;
if missing(numloans) the numloans=0;
run;
proc print data=test;
run;
The code, of course, could be reconfigured to be a SAS macro, in itself, but I didn't think it was worth the effort until we find out that it is close to what you were seeking.
Art