Date: Fri, 29 May 2009 09:05:03 -0400
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
hi ... here's one way
SASHELP.CLASS has 19 observations ... the new data set will have 18
set sashelp.class (firstobs=2 rename=(height=next_height));
two_heights = sum(height, next_height);
keep two_heights height next_height;
proc print data=test;
var height next_height two_heights;
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
> 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?