Calcite | Level 5

## Player Database - Count number of appearances by each player

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

1 ACCEPTED SOLUTION

Accepted Solutions
Diamond | Level 26

## Re: Player Database - Count number of appearances by each player

My mistake it should say

``player=p(i);``
--
Paige Miller
5 REPLIES 5
Diamond | Level 26

## Re: Player Database - Count number of appearances by each player

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;``````
--
Paige Miller
Calcite | Level 5

## Re: Player Database - Count number of appearances by each player

Thanks for the quick response Paige. Seem to be getting the below error.

22 data stacked;
23 set gw_stat_v2;
24 array p player1-player23;
25 do i=1 to dim(p);
26 player=player(i);
______
68
ERROR 68-185: The function PLAYER is unknown, or cannot be accessed.
Diamond | Level 26

## Re: Player Database - Count number of appearances by each player

My mistake it should say

``player=p(i);``
--
Paige Miller
Tourmaline | Level 20

## Re: Player Database - Count number of appearances by each player

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;``````
Calcite | Level 5

## Re: Player Database - Count number of appearances by each player

Thanks guys much appreciated

Discussion stats
• 5 replies
• 352 views
• 2 likes
• 3 in conversation