I know this is not a best way of achieving this but following code does what I want. But still I am looking for some way to achieve this directly from "Proc Report" /**** Calculate Sum in a seperate dataset*/ PROC SQL; CREATE TABLE WORK.QUERY_FOR_TEMPDATA AS SELECT t1.Zone, t1.SubZone, (sum(t1.Product1Sale)) AS Product1SaleSum, (sum(t1.Product2Sale)) AS Product2SaleSum FROM WORK.TEMPDATA t1 GROUP BY t1.Zone, t1.SubZone; QUIT; /**** Join that dataset with original dataset*/ PROC SQL; CREATE TABLE WORK.TempDataMod AS SELECT t2.Zone, t2.SubZone, t2.SaleMonth, t2.Product1Sale, t2.Product2Sale, t1.Product1SaleSum, t1.Product2SaleSum FROM WORK.QUERY_FOR_TEMPDATA t1 RIGHT JOIN WORK.TEMPDATA t2 ON (t1.Zone = t2.Zone) AND (t1.SubZone = t2.SubZone) ORDER BY t2.Zone, t2.SubZone, t2.SaleMonth; QUIT; /**** Use this new modified data set for reporting*/ proc report data=work.TempDataMod; column Zone SubZone SaleMonth, (Product1Sale Product2Sale) Product1SaleSum Product2SaleSum ; define zone / group; define subzone/group; define salemonth/across ''; define product1sale/analysis; define product2sale/analysis; define Product1SaleSum/group; define Product2SaleSum/group; break after zone / summarize; compute after zone; zone=''; subzone="Sum:"; endcomp; rbreak after / summarize; compute after; zone=''; subzone="Grand Sum:"; endcomp; run; quit;
... View more