From: Al on

All:

Here is the data i have , I am trying to compare the values of FS to
the consecutive values of LS and so on
i.e for SNO = 1 , I am supposed to check FS = 12(first obs) with LS
= 12 (Second obs) and
FS = 13(second obs) with LS = 16(Third obs ) and
FS = 15(third obs) with LS = 14(fourth obs) and so on and generate
a flag for mismatch values

can any one help with the logic

Thanks in advance

SNO FS LS
1 12
1 13 12
1 15 16
1 16 14
2 22
2 33 22
2 44 22
From: Al on
On Mar 9, 3:47 pm, Al <ali6...(a)gmail.com> wrote:
> All:
>
> Here is the data  i have , I am trying to compare the values of FS to
> the consecutive values of LS  and so on
> i.e  for SNO = 1 , I am supposed to check FS = 12(first obs) with  LS
> = 12 (Second obs) and
> FS = 13(second obs) with LS = 16(Third obs ) and
> FS = 15(third obs) with  LS  = 14(fourth obs) and so on  and generate
> a flag for mismatch values
>
> can any one help with the logic
>
> Thanks in advance
>
> SNO FS  LS
> 1   12
> 1   13  12
> 1   15  16
> 1   16  14
> 2   22
> 2   33  22
> 2   44  22

Any Help on this .. Please
Thanks
From: gupt on
On Mar 10, 4:20 am, Al <ali6...(a)gmail.com> wrote:
> On Mar 9, 3:47 pm, Al <ali6...(a)gmail.com> wrote:
>
>
>
> > All:
>
> > Here is the data  i have , I am trying to compare the values of FS to
> > the consecutive values of LS  and so on
> > i.e  for SNO = 1 , I am supposed to check FS = 12(first obs) with  LS
> > = 12 (Second obs) and
> > FS = 13(second obs) with LS = 16(Third obs ) and
> > FS = 15(third obs) with  LS  = 14(fourth obs) and so on  and generate
> > a flag for mismatch values
>
> > can any one help with the logic
>
> > Thanks in advance
>
> > SNO FS  LS
> > 1   12
> > 1   13  12
> > 1   15  16
> > 1   16  14
> > 2   22
> > 2   33  22
> > 2   44  22
>
> Any Help on this .. Please
> Thanks
hi, try this it might help you..........

data new;
infile datalines truncover;
input SNO FS LS;
cards;
1 12
1 13 12
1 15 16
1 16 14
2 22
2 33 22
2 44 22
;
run;

data new1;
set new;
if ls=lag(fs) then match=1;
else match=0;
run;

proc print;
run;
From: Richard A. DeVenezia on
On Mar 12, 1:14 am, gupt <pvsgu...(a)gmail.com> wrote:
> data new;
> infile datalines truncover;
> input SNO FS  LS;
> cards;
> 1   12
> 1   13  12
> 1   15  16
> 1   16  14
> 2   22
> 2   33  22
> 2   44  22
> ;
> run;
>
> data new1;
> set new;

> if ls=lag(fs) then match=1;

You probably want to amend this statement to be

by SNO;
match = (lag(fs)=ls) and not first.SNO;


--
Richard A. DeVenezia
http://www.devenezia.com