Statalist


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

Re:st: break when using mata within a loop


From   Valérie Orozco <Valerie.Orozco@toulouse.inra.fr>
To   statalist@hsphsun2.harvard.edu
Subject   Re:st: break when using mata within a loop
Date   Fri, 27 Jul 2007 13:06:33 +0200

Hi Carlos,

maybe you can do the loop in the mata language (and so open only one time Mata)...The code following works well. I don't know if it helps you.

mata :

for (contvar=1; contvar<=3; contvar++) {
a=`contvar'
a
printf("i=%g\n", contvar)
}

end

Valérie


st: break when using mata within a loop

------------------------------------------------------------------------
*From* Carlos Eduardo Hernández Castillo <cehc84@hotmail.com <mailto:cehc84@hotmail.com>>
*To* statalist@hsphsun2.harvard.edu <mailto:statalist@hsphsun2.harvard.edu>
*Subject* st: break when using mata within a loop
*Date* Thu, 26 Jul 2007 23:56:54 -0500

------------------------------------------------------------------------
Hello everyone. Thanks in advance for your help. I am trying to use mata within a forvalues loop. However Stata stops the execution of the code when arriving to the "mata:" line. Could you please tell me how to overcome this problem? This is the Stata output:

.. forvalues contvar = 1(1)3 {
2. mata:
3. a=1
4. a
5. end
--Break--
r(1);

end of do-file
--Break--
r(1);

Thanks again for your help.

Carlos Eduardo Hernandez Castillo



--
*******************************************************
Valérie OROZCO
INRA ESR Toulouse, FRANCE
ESR INRA - BP52627 - 31326 Castanet Tolosan Cedex
Valerie.Orozco@toulouse.inra.fr
05-61-28-50-97 ou 05-61-12-85-91
*******************************************************


*
* 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index