Date: Wed, 12 Dec 2007 10:58:51 -0500
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: Summing up the last 5 observations
In-Reply-To: <36a3d30f-c543-4559-b8ff-8b999e1f0b23@r60g2000hsc.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
I normally stay away from the LAG functions, but this is a perfect
opportunity to use them. ;-)
data newfile;
set testfile;
last_5 = test + lag(test) + lag2(test) + lag3(test) + lag4(test);
run;
Mike Rhoads
Westat
RhoadsM1@Westat.com
-----Original Message-----
From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu]
On Behalf Of higgoboss@yahoo.co.uk
Sent: Wednesday, December 12, 2007 9:57 AM
To: sas-l@uga.edu
Subject: Summing up the last 5 observations
I have been struggling to get this done in sas - all I want to do is
create the column last 5 which sums up the last 5 observations of
column test
test last_5
0
0
0
1
0 1
1 2
1 3
0 3
1 3