you can use mata to generate all the permutation, but if you have 50 unique values, the number of variables will be 50!, which is impossible for stata to hold. The code is, suppose you have the data in var x
mata
j=0
st_view(X = ., ., "x")
info = cvpermutesetup(X)
while ((p=cvpermute(info)) != J(0,1,.)) {
j++
x="p"+strofreal(j)
st_addvar("float",x)
st_store(.,x,p)
}
f ...
you can use mata to generate all the permutation, but if you have 50 unique values, the number of variables will be 50!, which is impossible for stata to hold. The code is, suppose you have the data in var x
mata
j=0
st_view(X = ., ., "x")
info = cvpermutesetup(X)
while ((p=cvpermute(info)) != J(0,1,.)) {
j++
x="p"+strofreal(j)
st_addvar("float",x)
st_store(.,x,p)
}
for data from 1 to 6, the code will generate 720 extra variables, then you can loop for the pairs. But your problem is based on 50 values, you can see how large 50! is, seems not realistic.