Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Locals and Mata Script execution

From   Bruno Boynard <>
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):


for(i=1;i<=lX;i++) {
    stata("local x=c[1,1]")
    stata("local M J(8000,5,0)")
    stata("local Z M`x'=`M'")


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,

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index