|
John,
Not sure of your question but if you are looking for a "Look Ahead"
function in SAS there isn't one readily available. However, if you
re-sort your data in descending order, then the LAG function will sort
of simulate a "Look Ahead" function after you re-sort the data in its
orginal order.
Look at Tips and Techniques on my web site "www.sasconsig.com" and
scroll through. I believe I provided a tip on Look Ahead code using LAG
function.
HTH,
Charles Patridge
Charles_S_Patridge@prodigy.net
In article
<D1539850DE7DD111B6400008C720C4A8012D0921@cfc-mail.cfc.wa.gov>,
"Lund, Pete" <Peter.Lund@CFC.WA.GOV> wrote:
> John,
> There really isn't a "look ahead" kind of function. However, LAG()
is
> just really the default of the LAGn() function, which allows n looks
back.
> You can use this to get what you want by treating each observation as
"next
> years" value. Back one observation is "this year" and back two
observations
> is "last year." Something like:
>
> data years_3(drop=returns);
> set revrslag;
>
> LastYear = lag2(returns);
> ThisYear = lag(returns);
> NextYear = returns;
>
> Year = Year - 1;
> run;
>
> ----------------------------------------------------------------------
> Pete Lund
> WA State Caseload Forecast Council
> 515 15th Ave SE
> Olympia, WA 98504-0962
> (360) 902-0086 voice
> (360) 902-0084 fax
> (360) 971-0962 pager
> peter.lund@cfc.wa.gov
> ----------------------------------------------------------------------
>
> -----Original Message-----
> From: John J. Shon [mailto:pjshon@GSBPHD.UCHICAGO.EDU]
> Sent: Monday, June 26, 2000 9:50 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: "reverse" lag
>
> dear SAS addicts:
>
> data revrslag;
> input year returns;
> cards;
> 1981 .120
> 1982 .134
> 1983 .155
> 1984 .234
> 1985 .346
> 1986 .111
> ;
> run;
>
> i am trying to create a dataset that has a current year observation,
prior
> year observation, and future year observation (eg, for 1983, i'd want
1982
> and 1984 data). prior year is easily done with lag(), but is there a
> simple way to get the future year observation (ie, without reverse
sorting
> and using the lag() function)?
>
> thanks if you know. i'm sure this is an easy one...
>
> John Shon
>
> ===================================================
> University of Chicago, Graduate School of Business
> PhD Candidate, 2001
> (yes, you can get a PhD in business.)
> (no, i have no idea what i'll do afterwards.)
> (no, i don't love business THAT much.)
>
--
Charles Patridge - PDPC, Ltd.
172 Monce Road - Burlington, CT 06013 USA
Phone: 860-673-9278 or 860-675-9026
Email: Charles_S_Patridge@prodigy.net - Web: www.sasconsig.com
Sent via Deja.com http://www.deja.com/
Before you buy.
|