Hi guys,
I am looking to create a player database to count number of appearances by players over a period of time.
For example
Match Player 1 Player 2 Player 3 Player 4 Player 5
1 Smith Jones Brown Thomas Kerr
2 Smith Jones Brown Thomas Kerr
3 Smith Jones Brown Thomas Kerr
4 Smith Jones Brown Thomas Kerr
5 Smith Kerr Brown Thomas Phillips
So for instance Kerr has made 5 appearances but in different positions whereas Jones has made 4 appearances all in the same position. I want to be able to loop through each position ( 5 in this scenario) to check how many appearances each person has made.
Any help would be appreciated.
Thanks, Paul
I would stack the positions into one, and then count.
data stacked;
set have;
array p player1-player5;
do i=1 to dim(p);
player=player(i);
output;
end;
drop player1-player5;
run;
proc freq data=stacked;
table player/out=_counts_;
run;
My mistake it should say
player=p(i);
HI @PKERR85 same idea with a proc transpose
data have;
input Match (Player1 Player2 Player3 Player4 Player5) (:$32.);
cards;
1 Smith Jones Brown Thomas Kerr
2 Smith Jones Brown Thomas Kerr
3 Smith Jones Brown Thomas Kerr
4 Smith Jones Brown Thomas Kerr
5 Smith Kerr Brown Thomas Phillips
;
proc transpose data=have out=temp(keep=col1 rename=col1=player);
by match;
var player1-player5;
run;
proc freq data=temp;
table player/out=want;
run;
Thanks guys much appreciated
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.