Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[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 <[email protected]>
To
"[email protected]" <[email protected]>
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
[email protected]
On 7 June 2013 18:38, Ignacio López De Ullibarri Galparsoro <[email protected]> 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/