Date: Fri, 4 Nov 2005 08:34:01 -0800
Reply-To: YI <yi_zhu_web@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: YI <yi_zhu_web@HOTMAIL.COM>
Organization: http://groups.google.com
Subject: Create a Roll Over Sum
Content-Type: text/plain; charset="iso-8859-1"
Can anyone guide me how to figure out the following problem? Having a
certain variable of data, I want to create another variable that sums
up previous certain number of rows (including the current row) at each
line.
For example:
With data Var1, and starting at row Three (say everything 3 steps), I
want to create a variable Var2 that sums up previous 2 consecutive rows
and the current row of Var1.
Like the following:
Var1 Var2
1
2
3 6 <-- sum(1+2+3)
4 9 <-- sum(2+3+4)
5 12 ... ...
6 15
7 18
8 21
9 24 <--sum(7+8+9)
Thanks!
|