| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: saving to locals in Mata
sacrificial lamb
Julian said
I am having trouble saving to locals using Mata. The following ADO
code demonstrates my problem:
***example.ado code***
program example
version 9.2
mata: example()
end
mata:
void example()
{
t = "string"
st_local("my_local",t)
stata(`" di "my_local is `my_local'""')
}
end
***end example.ado code***
No problem if instead you include the line
di "the local is `my_local'"
in the Stata program. It might be that the stata() function is
executed in a different context than that of the calling program (in
which my_local is local). For instance,
program example
version 9.2
local test test
mata: example()
di "the local is `my_local'"
end
mata:
void example()
{
t = "string"
st_local("my_local",t)
stata(`" di "my_local is `my_local'""')
stata(`" di "test is `test'""')
}
end
does not display the value of test within Mata, either, although it
is certainly defined in program example. But then why not just work
with my_local back in the Stata program, anyway?
Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html
*
* 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/