Creating Cumulative Totals
Here's how to update a SAS data set to include cumulative totals for a numeric variable.In this example, he goal is to create a new variable ("sumT") that is a cumulative total of the variable tsippT:
data one;
input pulldate MMDDYY10.
tsippT 12-14
tsippC 15-18
count 20;
format pulldate date7.;
cards;
08/04/2006 34 24 1
09/25/2006 343 200 2
10/20/2006 678 398 3
11/03/2006 713 406 4
02/07/2007 857 451 5
;
run;
proc sort data=one;
by pulldate;
run;
data two;
set one;
by pulldate;
if first.count then sumT=0;
sumT+tsippT;
if last.pulldate;
run;
proc print data=two;
run;