Solved
Contributor
Posts: 21

# values in another column

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_id player_grp v1 v2 v3 10 10 2 3 4 11 11 10 1 4 6 12 12 13 2 6 8 13 13 12 3 7 9

Accepted Solutions
Solution
‎05-09-2015 09:56 AM
Super User
Posts: 10,784

## Re: Lookup values in another column

```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

All Replies
Solution
‎05-09-2015 09:56 AM
Super User
Posts: 10,784

## Re: Lookup values in another column

```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

Contributor
Posts: 21

## Re: Lookup values in another column

Thank a lot Xia KEshan

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 198 views
• 0 likes
• 2 in conversation