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 <[email protected]>
To   [email protected]
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 <[email protected] <mailto:[email protected]>>
*To* [email protected] <mailto:[email protected]>
*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
[email protected]
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index