Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: re: how do I suppress output in Mata?


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: how do I suppress output in Mata?
Date   Sun, 15 Nov 2009 07:27:52 -0500

<>
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/



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