borrowed data from Hima and code from PGstate: data have; input date num 3.; informat date mmddyy8.; cards; 01/8/2012 9 02/2/2012 5 01/7/2012 9 03/2/2012 8 01/31/2012 10 01/30/2012 6 ; run; proc sql; create table periods as select distinct intnx("month",date,0,"beginning") as period format=mmyyd7., intnx("day",date,0,"beginning") as periodBeg format=mmddyy10., intnx("day",date,0,"end") as periodEnd format=mmddyy10. from have; create table want as select period, sum(num) as total from periods inner join have on date between periodBeg and periodEnd group by period; drop table periods; quit; proc print data=want;run; Obs period total 1 01-2012 34 2 02-2012 5 3 03-2012 8 Linlin
... View more