LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: higgoboss@yahoo.co.uk
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


Back to: Top of message | Previous page | Main SAS-L page