Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: mata: Colon operators result in matrix output to screen?


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: mata: Colon operators result in matrix output to screen?
Date   Mon, 3 Dec 2007 11:47:20 -0600

On Dec 3, 2007, at 1:03 PM, Thomas Masterson wrote:
A mata question: when I use the function affinity() [code below] I get the results I expect, but the colon comparison operations result in the resulting matrix being written to the Stata results window [quite a nuisance for logging purposes]. Any thoughts why this happens?

You need to assign the result to something -- otherwise (like other Mata operators) the result is printed to the screen:


: foo = (1,2,3)

: foo :<= 2
1 2 3
+-------------+
1 | 1 1 0 |
+-------------+

: foo = (foo :<= 2)

: foo
1 2 3
+-------------+
1 | 1 1 0 |
+-------------+


Also, be aware of the order of operations. The operators :<= and :>= both have higher precedence than either + or -, which means that you may need to use parentheses.


-- Phil

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




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