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]

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


From   Ignacio López De Ullibarri Galparsoro <ilu@udc.es>
To   statalist <statalist@hsphsun2.harvard.edu>
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index