Code: data players;
input Name $ Team $ Ability $;
cards;
Player1 Team1 Level1
Player2 Team1 Level1
Player3 Team1 Level1
Player4 Team1 Level1
Player5 Team1 Level2
Player6 Team1 Level2
Player7 Team1 Level2
Player8 Team1 Level2
Player9 Team2 Level1
Player10 Team2 Level1
Player11 Team2 Level1
Player12 Team2 Level1
Player13 Team2 Level2
Player14 Team2 Level2
Player15 Team2 Level2
Player16 Team2 Level2
;
run;
data matches;
input Pl1 $ Pl2$;
cards;
Player1 Player9
Player2 Player10
Player3 Player11
Player4 Player12
Player5 Player13
Player6 Player14
Player7 Player15
Player8 Player16
;
run;
proc sql;
create table possible_matches as
select a.Name as Pl1, b.Name as Pl2/*, a.Team as Pl1Team, b.Team as Pl2Team, a.Ability as Pl1Ability, b.Ability as Pl2Ability*/
from players (where=( Team='Team1')) a, players (where =(Team='Team2')) b
except
select Pl1, Pl2 from matches;
quit;
data possible_matches;
set possible_matches;
fred = ranuni(0);
run;
proc sort data=possible_matches;
by Pl1 fred;
run;
data next_match(drop=fred Pl2_exustive_lst f);
length Pl2_exustive_lst $30000;
set possible_matches;
retain Pl2_exustive_lst f;
by Pl1 fred;
if first.Pl1 then do;
f=1;
if f=1 and findw(Pl2_exustive_lst,Pl2) =0 then do;
Pl2_exustive_lst=cats(strip(Pl2_exustive_lst)||' , '||Pl2);
f=0;
output;
end;
end;
if f=1 and findw(Pl2_exustive_lst,Pl2) =0 then do;
Pl2_exustive_lst=cats(strip(Pl2_exustive_lst)||' , '||Pl2);
f=0;
output;
end;
run;
/*
data matches;
set matches next_match;
run;
*/ Please let us know if it worked.
... View more