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
Player | Game | Score1 |
1 | D1 | 10 |
1 | D2 | 20 |
1 | D3 | 30 |
2 | D1 | 40 |
2 | D2 | 50 |
2 | D3 | 10 |
2 | D4 | 20 |
2 | D5 | 30 |
3 | D1 | 20 |
3 | D2 | 10 |
3 | D3 | 30 |
Table2 Player | Game | Score2 |
1 | D1 | 10 |
1 | D2 | 15 |
1 | D3 | . |
2 | D1 | 40 |
2 | D2 | 5 |
2 | D3 | . |
2 | D4 | 15 |
2 | D5 | 10 |
3 | D1 | 5 |
3 | D2 | . |
3 | D3 | 15 |
Output Required---Where Score1>Score2
Player | Game | Score1 | Score2 |
1 | D2 | 20 | 15 |
1 | D3 | 30 | 15 |
2 | D2 | 50 | 5 |
2 | D3 | 10 | 5 |
2 | D4 | 20 | 15 |
3 | D1 | 20 | 5 |
3 | D2 | 10 | 5 |
3 | D3 | 30 | 15 |
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.
Hi Reeza,
Thanks for looking into this, I updated my initial post and hope this is making sense.
Thanks,
Gopi
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.