BookmarkSubscribeRSS Feed
gopilth
Calcite | Level 5

Hi,


In the following scenario, I should output scores only if score1> score2 for corresponding games, for each player for each game but if a score is "." then I should use latest score for that player from  games before '.' ;

for example if score2 of D3 is "." then compare Score1 of D3 with latest score2 before D3 (Latest score2 of D1orD2, cannot use score2 from D4 or above).

any suggestions?

Thanks in advance for your help.


Table1

PlayerGameScore1
1D110
1D220
1D330
2D140
2D250
2D310
2D420
2D530
3D120
3D210
3D3

30

Table2 Player

GameScore2
1D110
1D215
1D3.
2D140
2D25
2D3.
2D415
2D510
3D15
3D2.
3D315

Output Required---Where Score1>Score2

PlayerGameScore1Score2
1D22015
1D33015
2D2505
2D3105
2D42015
3D1205
3D2105
3D33015


3 REPLIES 3
Reeza
Super User

What?

Post a sample of what you want your output to look like please.

This looks like an update but I'm not sure. You mention time but I don't see any indication of time in the dataset.

gopilth
Calcite | Level 5

Hi Reeza,

Thanks for looking into this, I updated my initial post and hope this is making sense.

Thanks,

Gopi

art297
Opal | Level 21

Here is one way:

data want (drop=last);

  set table1;

  set table2;

  retain last;

  by player game;

  if first.player then call missing(last);

  if not missing(score2) then last=score2;

  if missing(score2) then score2=last;

  if score1 gt score2 then output;

run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 893 views
  • 0 likes
  • 3 in conversation