Help using Base SAS procedures

Selecting latest score

Reply
Occasional Contributor
Posts: 10

Selecting latest score

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


Super User
Posts: 17,784

Re: Selecting latest score

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.

Occasional Contributor
Posts: 10

Re: Selecting latest score

Hi Reeza,

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

Thanks,

Gopi

PROC Star
Posts: 7,360

Re: Selecting latest score

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;

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