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