[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
[no subject]
Nick Cox writes:
This ia good progress! How would you generalise your match-ups
AB CH DG EF to arbitrary even numbers of teams?
How about this?
Tom
* --------------------------------------
clear
* set # teams before running
local teams 16
local obs = `teams' - 1
set obs `obs'
gen round = _n
gen T1=1
foreach t of numlist 2/`teams' {
gen T`t' = `t'-1 + round
}
foreach t of numlist 2/`teams' {
qui replace T`t' = T`t'-`obs' if T`t'>`teams'
}
local match = `teams'/2
egen field1 = concat(T1 T2), punct("_")
foreach m of numlist 2/`match' {
local l = `m' + 1
local k = `teams' + 2 - `m'
egen field`m' = concat(T`l' T`k'), punct("_")
}
l field*, sep(2)
*confirm no repeats
preserve
drop T*
reshape long field, i(round) j(f)
qui tab field
return list
if r(N) == r(r) {
di "OK, each matchup occurs exactly once"
}
else {
di "ERROR, some matchups are duplicated"
}
restore
* --------------------------------------
-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept
**********************************************************************
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |