Date: Thu, 1 Feb 2007 02:47:33 -0800
Reply-To: sylvain.willart@GMAIL.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: sylvain.willart@GMAIL.COM
Organization: http://groups.google.com
Subject: Re: Urgent: RE:How to compare subsequent values in a column?
In-Reply-To: <A99CFB142B0B45489B4123C28ED33E3C14ECAF24@EVSEMAIL.Evalueserve.com>
Content-Type: text/plain; charset="iso-8859-1"
On 1 fév, 08:43, peeyush.agar...@EVALUESERVE.COM (Peeyush Agarwal)
wrote:
> Dear All,
>
> Please refer to the email below.
>
> I would be obliged if you can asap provide a solution.
>
> Regards,
> Peeyush
>
> -----Original Message-----
> From: Peeyush Agarwal [mailto:Peeyush.Agar...@EVALUESERVE.COM]
> Sent: Wednesday, January 31, 2007 7:17 PM
> To: S...@LISTSERV.UGA.EDU
>
> Cc: Peeyush Agarwal
> Subject: How to compare subsequent values in a column?
>
> How to do a simple ratio calculation << row2 value/row1 value >> and so
> on
> for the whole data set?
>
> The next aspect of my problem relates to doing this ratio calculation
> for
> a
> varying number of grouped observations. If there are many groups in the
> data and each group has several rows and the number of rows do not
> match,
> how we can do it then. I can try to work around the second issue, but
> would
> need some quick help for the first issue.
>
> The information in this e-mail is the property of Evalueserve and is
> confidential and privileged. It is intended solely for the addressee.
> Access to this email by anyone else is unauthorized. If you are not the
> intended recipient, any disclosure, copying, distribution or any action
> taken in reliance on it is prohibited and will be unlawful. If you
> receive
> this message in error, please notify the sender immediately and delete
> all
> copies of this message.
>
> The information in this e-mail is the property of Evalueserve and is confidential and privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and will be unlawful. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
hello,
Perhaps you should use a lag operator .
for example , if your dataset look like :
var1 var2
2 5
1 3
7 9
the code :
data datasetname ; set datasetname ;
lagv2 = lag(var2);
run ;
will give you :
var1 var2 lagv2
2 5 .
1 3 5
7 9 3
then , if you compare var2 and lagv2 , you actually have the
comparison you wanted btw subsequent rows.
note you can use operator lag2 , lag3, lagN if you want to compare not
subsequent row (for example, for row 1 and row 4 you may use : lagv2
= lag3(var2) );
hope it helps
|