Dear Statalist,
I have twenty four variables namely 1 , 2, 3, ...,24,and I need to pair each
and every variable with each
one of the other twenty three variable such that I have the following 276
pairs of variables : 1 2,1 3,1 4,
...,1 23, 1 24, 2 3, 2 4, ..., 2 24, 3 4,..., 3 24,4
5,....,4 24,5 6, .......,.......,23 24.
I have managed to do this task with the help of the following code :
drop _all
set obs 576
gen a = .
gen b = .
gen n = .
local i = 1
while `i'<= 24 {
local u = 1
while `u'<= 24 {
local a = [`i'-1]*24 + `u'
replace a = `i' in `a'
replace b = `u' in `a'
replace n = `a' in `a'
local u = `u'+1
}
local i = `i'+1
}
drop if a>=b
What I need to do is to separate these 276 pairs of variables into 23 groups
,each group containing 12 pairs of
variables whereby no variable may repeat itself in any one group.Example:
1 2 , 3 4, 5 6, 7 8 , 9 10, 11 12 , 13 14 , 15 16
,17 18 , 19 20 , 21 22 , 23 24
1 3 , 2 4, 5 7, 6 8 , ..........
.............................. ..............., 22
24
.................
.................
1 13, 2 14, ............. .......................
............... ......., 11 23, 12 24
Can anyone please indicate any code that I can use so that I may not have to
do such an arduous process
by hand,especially when the number of variables is bigger ?
*
* 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/