Date: Mon, 26 Jun 2000 16:07:01 -0400
Reply-To: Bob Burnham <Robert.A.Burnham@DARTMOUTH.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bob Burnham <Robert.A.Burnham@DARTMOUTH.EDU>
Organization: Dartmouth College, Hanover, NH, USA
Subject: Re: "reverse" lag
John,
I wish that I could remember where I picked up this tip --
but it might be what you are looking for:
data example;
input year return;
cards;
1981 .120
1982 .134
1983 .155
1984 .234
1985 .346
1986 .111
;
run;
data final;
set example;
set example(rename=(return=nextret) firstobs=2);
run;
proc print data=final noobs;
run;
Produces:
YEAR RETURN NEXTRET
1982 0.120 0.134
1983 0.134 0.155
1984 0.155 0.234
1985 0.234 0.346
1986 0.346 0.111
"John J. Shon" <pjshon@GSBPHD.UCHICAGO.EDU> wrote in message
news:Pine.GSO.3.96.1000626114228.17952C-100000@gsbphd.uchica
go.edu...
> 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.)
|