Bookmark and Share

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]

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


From   Ignacio López De Ullibarri Galparsoro <[email protected]>
To   statalist <[email protected]>
Subject   st: On the use of the stata() funtion of Mata
Date   Fri, 7 Jun 2013 19:38:55 +0200 (CEST)

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index