Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: On the use of the stata() funtion of Mata


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: On the use of the stata() funtion of Mata
Date   Fri, 7 Jun 2013 20:25:38 +0100

it's best to avoid attempts to mix local macro manipulation and  Mata.

See  Gould, W. and Cox, N. J. 2011.
Stata tip 100: Mata and the case of the missing macros.
Stata Journal 11: 323-324.


Nick
njcoxstata@gmail.com


On 7 June 2013 18:38, Ignacio López De Ullibarri Galparsoro <ilu@udc.es> wrote:
> Dear Statalist users,
>
> I am having some difficulties using the stata() function of Mata in .ado files. I am using Stata 12.1 for Linux.
>
> An .ado file with the following content (note the 'protection', i.e. the backslash, of the macro) works like an indeed esoteric equivalent of -sysuse dataset, clear-. Try, e.g., -example, dataset(auto)-, which has the same effect than -sysuse auto-.
>
> ********************* beginning of file ********************
> pr example
> vers 12.1
> syntax, dataset(string)
> mata: callsysuse()
> end
>
> vers 12
> mata:
> function callsysuse(){
>    stata("sysuse \`dataset', clear")
> }
> end
> ************************ end of file ***********************
>
> Now, the Stata M manual (page 822) says that the extended syntax of the stata() function:
>
> stata(cmd, nooutput, nomacroexpand)
>
> "does the same thing than stata(cmd, nooutput), but, before execution, suppressing expansion of any macros contained in cmd if nomacroexpand is not equal to 0".
>
> Nevertheless, the following version of the previous code does not work:
>
> ********************* beginning of file ********************
> pr example
> vers 12.1
> syntax, dataset(string)
> mata: callsysuse()
> end
>
> vers 12
> mata:
> function callsysuse(){
>    stata("sysuse `dataset', clear", 0, 1)
> }
> end
> ************************ end of file ***********************
>
> Am I doing (or interpreting) something erroneously? Thanks for any hints,
>
> Ignacio Lopez de Ullibarri
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index