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]

Re: st: Locals and Mata Script execution


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Locals and Mata Script execution
Date   Mon, 3 Sep 2012 17:29:45 +0100

Don't try to do this. It's probably not impossible, but it is a small
nightmare. Have a look at

SJ-11-2 pr0052  . . . . Stata tip 100: Mata and the case of the missing macros
        . . . . . . . . . . . . . . . . . . . . . . . . W. Gould and N. J. Cox
        Q2/11   SJ 11(2):323--324                                (no commands)
        tip showing how to do the equivalent of Stata's macro
        substitution in Mata

Nick

On Mon, Sep 3, 2012 at 5:07 PM, Bruno Boynard <[email protected]> wrote:
> 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/
*
*   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