<>
I''m not sure what Kramer is unable to suppress, but this problem can be solved with much less code, I think:
clear all
set obs 100
g schl = _n
g u = runiform()
sort u
egen dist = cut(u), group(10)
g v = runiform()
sort v
drop u v
mata:
void district() {
real matrix distmat
st_view(d, ., "dist")
distmat = J(rows(d),rows(d),0)
for(i=1; i<=rows(d); i++) {
for(j=1; j<i; j++) {
distmat[i,j] = (d[i]==d[j])
}
}
_makesymmetric(distmat)
st_matrix("distmat", distmat)
}
end
mata: district()
l schl dist
mat list distmat
Kit Baum
[email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/