Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Locals and Mata Script execution


From   Bruno Boynard <[email protected]>
To   [email protected]
Subject   st: Locals and Mata Script execution
Date   Mon, 3 Sep 2012 13:07:07 -0300

I'm having trouble using Stata locals to run MATA scripts. I tried to
use the same code in different versions of Stata.

The issue is that I want to create a series of numbered matrix like
M1, M2, ... Mn. For that, I'm creating a counter in a loop and using
this counter for numbering the matrix. Finally I'm using a Stata local
in order to execute a MATA script.

Below is the final code (I've tried rewriting the code in different
ways but always with problems):

mata

s_total=10000
cR=55*s_total
lX=trunc(s_total/8000)+1
lZ=trunc(cR/8000)+1
i
for(i=1;i<=lX;i++) {
    c=i
    st_matrix("c",c)
    stata("local x=c[1,1]")
    stata("local M J(8000,5,0)")
    stata("local Z M`x'=`M'")
    `Z'
}

end

The main objective here is that I'd like to transfer a big Matrix (lX
lines in this point of the code and lZ in another) generated in Mata
to Stata database. To do that, I will split this Matrix in many others
and than export using a st_matrix in each one. I'm not using a st_view
because I'm generating matrix in MATA using different data bases and
the result is completely different from the original databases.

Thanks in advance,

Bruno
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index