Help using Base SAS procedures

compare the data

Reply
Occasional Contributor
Posts: 12

compare the data

Hi Team,

I have dataset with data this way

data dataset1;

input v1 v2;

cards;

10 12

12 21

23 22

22 45

33 24

; run;

And I am expecting the output which would diagonally compare and provides me the max value .. if diagonally  value was not found then it should return the same value with the column v2 (33 24 seen below)

output:-

V1 V2

10 21

23 45

33 24

Any help on this is really appreciated..

Contributor
Posts: 24

Re: compare the data

Hi,

I don't understand your output.

Could you elaborate!

output:-

V1 V2

10 21

23 45

33 24

Super Contributor
Posts: 490

Re: compare the data

data have;

input v1 v2;

cards;

10 12

12 21

23 22

22 45

33 24

run;

data want (keep=v1 v2);

set have end=last;

x=lag(v1);

if mod(_n_,2)=0  then do; v1=x; output; end;

else if last then output;

run;

Ask a Question
Discussion stats
  • 2 replies
  • 212 views
  • 0 likes
  • 3 in conversation