Statalist


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

Re: st: RE: Using Mata within a foreach loop = r(1)


From   "Abdel Rahmen El Lahga" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Using Mata within a foreach loop = r(1)
Date   Fri, 7 Dec 2007 09:17:34 +0100

I don't understand your loop but the code below work
*=====================
foreach i in 1 2 {
 mata: A=1,2
 mata: A
 mata: mata clear
 }
*======================
HTH
AbdelRahmen


2007/12/7, Nick Cox <[email protected]>:
> My guess is that you have to respect much more the fact
> that Stata and Mata are different languages. I don't think
> you can mix them quite like this.
>
> Something like
>
> foreach ... {
>         ...
>         myprog ...
>         ...
> }
>
> where -myprog- is a Stata program that calls Mata is more likely
> to succeed.
>
> As your real problem is different, further advice may wait upon
> details.
>
> Pablo Mitnik
>
> When I try to do stuff in Mata within a loop, in a do file, I receive
> the following error message:
>
> --Break--
> r(1);
>
> end of do-file
>
> --Break--
> r(1);
>
> I looked up r(1), and it says:
>
> [P]     error . . . . . . . . . . . . . . . . . . . . . . . . .  Return
> code 1
>         You pressed Break.  This is not considered an error.
>
> (Of course, I don't press break while the loop is executing.)
>
> The following very simple loop reproduces the error I get
>
> foreach i in 1 2 {
> mata:
> A=1,2
> A
> mata clear
> end
> }
>
> Any clue about what my mistake is?
>
> *
> *   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/
>


-- 
AbdelRahmen El Lahga
*
*   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