Date: Mon, 26 Jul 1999 11:53:38 +0200
Reply-To: Fabrizio.Arosio@ROTTA.COM
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Fabrizio.Arosio@ROTTA.COM
Subject: Re: Cumulative
Content-type: text/plain; charset=us-ascii
Tim,
there are at least three ways of doing what do you need.
1st method: using a doif..endif construct together with lag function
do if $CaseNum eq 1.
+Compute CumRev=Revenue.
else.
+Compute CumRev=Lag(CumRev)+Revenue.
end if.
Execute.
2nd method: using a scratch variable
Numeric #.
Compute CumRev=Revenue+#.
Compute #=CumRev.
Execute.
3rd method: using the leave command
Compute CumRev=CumRev+Revenue.
Leave CumRev.
Execute.
Hope this helps,
Fabrizio
Tim.Cooper@AVIS-EUROPE.COM on 26/07/99 10.03.53
Please respond to Tim.Cooper@AVIS-EUROPE.COM
To: SPSSX-L@LISTSERV.UGA.EDU
cc: (bcc: Fabrizio Arosio/RRL/IT)
Subject: Cumulative
How do you compute a cumulative value in a new variable?
For example, I have a variable called Revenue sorted ascending. In the
next
column, I want to calculate a cumulative value. How do I achieve this?
I've played around with LAG, but can't get it to work. I have 670,000
records, so I can't attempt it in Excel.
Thanks,
Tim Cooper
Group Marketing Data Analyst
Avis Europe Plc
Park Road, Bracknell,
Berkshire, UK RG12 2EW
* Direct Line: +44 (0)1344 417317