[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: previous and next records
From: "Chakravarthy, Venky" <Venky.Chakravarthy () PFIZER ! COM>
Date: 2002-12-30 20:34:32
[Download RAW message or body]
Jishnu,
What is your rule for the last record? Does it average the last three
values? Assuming this is true the first 2 and the last 2 observations should
have the same value.
data data1 ;
input d1 ;
cards ;
2
3
4
5
run ;
data data2 ( drop = __: ) ;
merge data1 (in = current) end = eof
data1 (in = next1 keep = d1 rename = (d1=__d1) firstobs = 2)
data1 (in = next2 keep = d1 rename = (d1=__d2) firstobs = 3) ;
retain __prev1 __prev2 ;
if _n_ = 1 then data_new = sum ( d1 , __d1 , __d2) / 3 ;
else if eof then data_new = sum ( __prev2 , __prev1 , d1 ) / 3 ;
else data_new = sum ( __prev1 , d1 , __d1 ) / 3 ;
__prev2 = __prev1 ;
__prev1 = d1 ;
run ;
Kind Regards,
__________________________
Venky Chakravarthy
E-mail: swovcc@hotmail.com
-----Original Message-----
From: Jishnu [mailto:jishguha@YAHOO.COM]
Sent: Monday, December 30, 2002 11:55 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: previous and next records
Hi all,
does anyone know how to get the previous recorda nd the next record.
I mean this is what I am trying to do
data data_new
2 (2+3+4)/3 (next and next)
3 (2+3+4)/3 (previous and next)
4 (3+4+5)/3 (previous and next)
5
Thanks
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be \
privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone \
else is unauthorized. If you are not an addressee, any disclosure or copying of the \
contents of this E-mail or any action taken (or not taken) in reliance on it is \
unauthorized and may be unlawful. If you are not an addressee, please inform the \
sender immediately.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic