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: Re: mata in program define
From
"Joseph Coveney" <[email protected]>
To
<[email protected]>
Subject
st: Re: mata in program define
Date
Tue, 5 Jul 2011 13:21:46 +0900
Zhi Su wrote:
I need to get bootstrap standard errors in a regression. And I need
to define a program that produce the standdard errors for a single
sample. When defining parts of the program that is involved with
matrix calculation, mata is used. When the part of mata command
complete, I need to use command "end". This "end" is taken by Stata as
the end of program define. However, it is not because several commands
need to be run after the parts of matrix calculation.
How can I let the stata know that the "end" is the "end" of mata
workspace, not the "end" of program define?
--------------------------------------------------------------------------------
You don't need to. Stata takes care of -end- in ado-files whether ending a
Stata program or ending a contained Mata program. And Stata and Mata programs
can be interleaved in an ado-file without a problem.
Joseph Coveney
=== begin ends.ado ===
program define ends
version 11.2
syntax
mata: speak()
end_of_ends
end
version 11.2
mata:
mata set matastrict on
void function speak() {
stata("end_of_speak")
}
end
program define end_of_ends
version 11.2
syntax
display in smcl as text ///
"But this {it:is} the end of ends.ado!"
end
program define end_of_speak
version 11.2
syntax
mata: endem()
end
mata:
mata set matastrict on
void function endem() {
printf("This ain't the end of Mata!\n")
}
end
=== end ends.ado ===
=== begin tryout.do ===
version 11.2
clear *
set more off
ends
exit
=== end tryout.do ===
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/