I am looking to create a player database to count number of appearances by players over a period of time.
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.
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;
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;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.