BookmarkSubscribeRSS Feed
mvk_sas
Calcite | Level 5

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..

2 REPLIES 2
BOBSAS
Calcite | Level 5

Hi,

I don't understand your output.

Could you elaborate!

output:-

V1 V2

10 21

23 45

33 24

mohamed_zaki
Barite | Level 11

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 691 views
  • 0 likes
  • 3 in conversation