If you create two static data sets that have all of the values you want: data work.statuses; order_status='Start'; output; order_status='End'; output; run; data work.fees; fee='paid'; output; fee='free'; output; run; Then you can use proc sql to get all of the possible combinations: proc sql; select m.calendar_day ,m.order_status ,m.fee ,sum(coalesce(h.no,0))as Total_No from ( select distinct t1.calendar_day, t2.order_status,t3.fee from work.have t1, work.statuses t2, work.fees t3) m left outer join work.have h on m.calendar_day=h.calendar_day and m.order_status=h.order_status and m.fee=h.fee group by m.calendar_day ,m.order_status ,m.fee; quit; produces 08JAN2013 End free 0 08JAN2013 End paid 0 08JAN2013 Start free 4 08JAN2013 Start paid 41
... View more