Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Re:distribution code


From   philippe van kerm <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: Re:distribution code
Date   Thu, 17 Jan 2008 00:28:37 +0100

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index