[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   Mon, 16 Nov 2009 06:34:43 -0500

I imagined that you wanted it in Stata, as you were returning it. This illustrates how you can get the object back to another Mata routine without having it displayed.

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])

void calldist() 
"Now in calldist"
"No output yet"

mata: calldist()


On Nov 16, 2009, at 2:33 AM, statalist-digest wrote:

> Kit - Thank you for not only suggesting the command "st_matrix" but for reworking my code to make it so much more efficient.  When you use the "return()" command instead, the whole matrix prints to the screen, which is unfortunate when the matrix is large.  
> The one question I have is that the "st_matrix" command saves the matrix district() creates to Stata, not mata.  I can then import the matrix to mata using the st_matrix command, but that seems like a waste of memory.  Is there a way to put it in mata in the first place?

Kit Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

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