BookmarkSubscribeRSS Feed
Xamius32
Calcite | Level 5

edit: Okay, I know what is missing. I still need to compare all of this to the other list I have, as mentioned in original post.

art297
Opal | Level 21

Are you saying that you have some "players" in your data who don't have any games that they played in?

Xamius32
Calcite | Level 5

yea, the original method I responded to did capture those (as in, if they didnt play,. no games would show up). Basically, I have a lineup, 10 players from each team in each game. I have a list of players, separately, that I want to see during the year. I had previously found out which games each player is in (some are in up to 100 games, some in none, some in 1 or 2.) Now, I just need to repeat that process but while adding the positions. I think it is messing up in terms of formatting and being able to read certain things.

art297
Opal | Level 21

If you can't solve it I suggest posting this as a new thread, supplying example data and the desired solution.

Xamius32
Calcite | Level 5

I think I figured out the main problem

Here is the data:

game_idplayer_1_idplayer_1_posplayer_2_idplayer_2_posplayer_3_idplayer_3_posplayer_4_idplayer_4_posplayer_5_idplayer_5_posplayer_6_idplayer_6_posplayer_7_idplayer_7_posplayer_8_idplayer_8_posplayer_9_idplayer_9_posplayer_10_idplayer_10_pos
1279577SS136860RF407812LF2040201B5018963B425877C445055CF5186142B346798P0

and so on.

Then I have a list:

player

2700

567432

123573

etc.

I want the following:

player games/positions

2700  1a  5b

so player 2700 appered in game 1 position a and then in game 5, position b. I have gotten to:

player games

2700    1, 2, 5 ,6

telling me player 2700 is in these games. But adding the positions seems more tricky.

art297
Opal | Level 21

So why not just merge that file with the final results?  e.g.:

data players;

  input player;

  cards;

5

7

10

;

proc sort data=players;

  by player;

run;

data h1;

input game

      player1 pos1 $

      player2 pos2 $

      player3 pos3 $

      player4 pos4 $

      player5 pos5 $

      player6 pos6 $

      player7 pos7 $

      player8 pos8 $

      player9 pos9 $

      player10 pos10 $;

  cards;

1 1 a 5 b 6 c 8 d 7 e 10 f 12 g 14 h 16 i 18 j

2 1 a 2 b 3 c 4 d 5 e 6 f 7 g 8 h 9 i 10 k

3 1 a 2 b 5 c 7 d 9 e 11 f 13 g 15 h 17 i 19 k

;

data need (keep=game player pos);

  set h1;

  array players(*) player1-player10;

  array position(*) $ pos1-pos10;

  do i=1 to 10;

    player=players(i);

    pos=position(i);

    output;

  end;

run;

proc sort data=need;

  by player game;

run;

data want (keep=player games);

  set need;

  length games $70;

  retain games;

  by player;

  game_and_pos=catx(" ",game,pos);

  if first.player then games=game_and_pos;

  else games=catx(",",games,game_and_pos);

  if last.player then output;

run;

data want;

  merge want players (in=inb);

  by player;

  if inb;

run;

Xamius32
Calcite | Level 5

I appreciate all your help. Looks like it works well

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 22 replies
  • 1454 views
  • 6 likes
  • 4 in conversation