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   Pablo Mitnik <pmitnik@ssc.wisc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Using Mata within a foreach loop = r(1)
Date   Fri, 07 Dec 2007 08:41:44 -0600

Thanks much for the suggestion . I can do that, and will probably do it.
But:
1. Is there a documented "end" command in Stata? Typing "help end" returns nothing, while "search end" only returns the Mata end statement.
2. If I am "within Mata," shouldn't everything be run in Mata?
Best,
Pablo

Maarten buis wrote:

--- Pablo Mitnik <pmitnik@ssc.wisc.edu> wrote:

This is rather inconvenient when you have a longer code to run in
Mata; and I haven't found any explanation in the manuals why the
code with "mata" and "end" shouldn't work -- my bet is that this is
a bug.
The end command is run in Stata not Mata, so you get the correct error
message.

The way to do this in a more convenient way is to first create a mata
function, so within the loop all you need is a single call to Mata.
This is explained in terms of .ado programming in -help m1_ado-.

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


__________________________________________________________
Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com

*
* 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/
--
Pablo A. Mitnik
University of Wisconsin-Madison (http://www.wisc.edu/ )
Department of Sociology ( http://www.ssc.wisc.edu/soc/)
Center on Wisconsin Strategy (http://www.cows.org/ )
1180 Observatory Drive
Room 7114A
Madison, WI 53706
TEL (608) 2621839
E-mail: pmitnik@ssc.wisc.edu

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