Date: Tue, 3 Nov 2009 07:16:42 -0800
Reply-To: Undo <vanessa.monro@CIGNA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Undo <vanessa.monro@CIGNA.COM>
Organization: http://groups.google.com
Subject: Cumulative subtract - easy for you, surely :-)
Content-Type: text/plain; charset=ISO-8859-1
Hello,
I've been trying to subtract pols_cancelling from the total (87249)
and then from previous row so I have a "descending" cumulative column
but I can't get it to subtract from the previous row, only from the
very top one. Could anyone help please?
So the column pols_remaining should actually show 87249, 87133, 86993,
86894 etc
The code I have done to get to this is at the bottom. Thanks very much
in advance.
TIME_TO_ pols_ pols_
CANCEL cancelling remainin
. 0 87249
0 116 87133
1 140 87109
2 99 87150
3 104 87145
4 104 87145
5 115 87134
6 185 87064
7 387 86862
8 380 86869
9 286 86963
10 284 86965
11 267 86982
12 336 86913
13 391 86858
14 499 86750
15 361 86888
data zzz;
set zz;
retain pols_remaining;
pols_remaining=87249;
by time_to_cancel;
if first.time_to_cancel then do;
pols_remaining=pols_remaining-pols_cancelling;end;
run;
|