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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 682 views
  • 0 likes
  • 3 in conversation