does this get you close? data howmany ;
infile datalines dsd delimiter=',';
input day DATE10. sumAdults deadFem deadMale totFem ;
format day date10. ;
datalines;
18 Apr 16,17,0,0,0
22 Apr 16,14,1,2,1
25 Apr 16,12,2,0,3
;
run;
title1 'raw input';
proc print data = howmany ;
run;
title1 'rolling total of dead female bugs' ;
proc sql ;
create table rolling as
select d.day,SUM(r.totfem) as rollingtotfem
from
howmany d
join
howmany r
on d.day >= r.day
group by d.day
;
quit;
run;
title1 'apply rolling total back to raw data' ;
proc sql ;
select d.day,d.sumAdults ,d.deadFem ,d.deadMale ,d.totFem , r.rollingtotfem
from howmany d
join rolling r
on d.day = r.day;
quit ;
run;
... View more