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 (May 2009, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 29 May 2009 09:05:03 -0400
Reply-To:     msz03@albany.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Zdeb <msz03@ALBANY.EDU>
Subject:      Re: need a sas function analagous to LAG function
Content-Type: text/plain;charset=iso-8859-1

hi ... here's one way

SASHELP.CLASS has 19 observations ... the new data set will have 18

data test; set sashelp.class; set sashelp.class (firstobs=2 rename=(height=next_height)); two_heights = sum(height, next_height); keep two_heights height next_height; run;

proc print data=test; var height next_height two_heights; run;

-- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> Hello All, > > I am familiar with the LAG function. It allows you to use a value of a > variable from the previous observation in hte calculation of a value of a > variable for the current observation. > > What I need to to is if there is a function which allows you to take a > value of a variable in the NEXT observation and use it in operations on the > current observation. If so, what is it? > > For example, I want to take the value of the variable UNIT in from the > observation that follows my current one and assign it to a new variable in > the current observation. > > something like: > > if unit='.' then unit1=next(unit); > > I don't think "next" is what i want, but what is? > > Thanks, > > Randall >


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