BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sudtej
Calcite | Level 5

Hi All,

I have a data with the unique player id's and their info(v1,v2,v3)

Also there is another column which shows if the player is playing in group(player_grp)

Player can play solo and/or play in the group.

for ex.

Have
player_idplayer_grpv1v2v3
1010234
1111 10146
1212 13268
1313 12379
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data have;
infile cards expandtabs truncover;
input player_id     $ player_grp & $10.     v1     v2     v3;
cards;
10     10         2     3     4
11     11 10      1     4     6
12     12 13      2     6     8
13     13 12      3     7     9
;
run;

proc sql;
create table want as
 select a.player_id,a.player_grp,mean(b.v1) as v1,mean(b.v2) as v2,mean(b.v3) as v3
  from have as a,have as b
   where findw(a.player_grp,strip(b.player_id))
    group by a.player_id,a.player_grp;
quit;

Xia Keshan

View solution in original post

2 REPLIES 2
Ksharp
Super User
data have;
infile cards expandtabs truncover;
input player_id     $ player_grp & $10.     v1     v2     v3;
cards;
10     10         2     3     4
11     11 10      1     4     6
12     12 13      2     6     8
13     13 12      3     7     9
;
run;

proc sql;
create table want as
 select a.player_id,a.player_grp,mean(b.v1) as v1,mean(b.v2) as v2,mean(b.v3) as v3
  from have as a,have as b
   where findw(a.player_grp,strip(b.player_id))
    group by a.player_id,a.player_grp;
quit;

Xia Keshan

Sudtej
Calcite | Level 5

Thank a lot Xia KEshan Smiley Happy

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
  • 2 replies
  • 749 views
  • 0 likes
  • 2 in conversation