Statalist


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

st: re: How to do a basic task in MATA that I cannot explain in English


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: How to do a basic task in MATA that I cannot explain in English
Date   Mon, 5 Jan 2009 08:54:54 -0500

<>
Tiago said

Taking the simple lines below, is it possible to create matrices TEST_1 to
TEST_100 too?


*/-----------------START--------------

clear
set obs 100
gene MATA = round(uniform()*45)
gene RULES = round(uniform()*15)
mata
X = st_data(.,("MATA", "RULES"))
Y = st_data(.,("RULES", "MATA"))
for (i=1; i<=100; i++) {
TEST = X[i,1]\Y[i,1]\X[i,1]\Y[i,1]
}
end
*/-----------------END-----------------


No. See http://ideas.repec.org/a/tsj/stataj/v8y2008i3p401-412.html for details. You are redefining the matrix TEST 100 times, not creating 100 matrices. To do the latter it is most helpful to use pointers.

Kit

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


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