Use a cross product to create all possible combinations:
proc sql;
create table summary as
select
a.as_of_date
,a.Channel
,a.QRM_Prod
,b.Note_Range
,sum(c.before_upb) as before_upb
,sum(c.after_UPB) as after_UPB
,sum(c.before_pmt) as before_pmt
,sum(c.after_pmt) as after_pmt
from
(select distinct
as_of_date
,Channel
,QRM_Prod
from msr_act_202102_202107) as a cross join
(select distinct
Note_Range
from msr_act_202102_202107) as b left join
msr_act_202102_202107 as c on
a.as_of_date=c.as_of_date and
a.Channel=c.Channel and
a.QRM_Prod=c.QRM_Prod and
b.Note_Range=c.Note_Range
group by
a.as_of_date
,a.Channel
,a.QRM_Prod
,b.Note_Range
;
quit;
(untested)
... View more