An alternative solution to this problem (just for the exercise, really)... I think it works for any even number of teams. I could not make it any shorter.
clear /* start from empty dataset */
loc K = 8 /* number of 'teams' -- assumed even*/
set obs `=`K'*(`K'-1)/2'
gen t = ceil(2*_n/`K') /* t identifies a round of matches */
gen j = mod(_n , `K'/2) + 1 /* j identifies each matches within a round */
gen home = int((t+j-1)/`K') + mod((t+j-1), `K')
gen away = cond(j==1, `K', int((`K'-j+t)/`K') + mod((`K'-j+t),`K') )
sort t j
list , separator(`=`K'/2')
Philippe
---------------------------------
---------------------------------
RE: st: RE: Re:distribution code