Dear Stata community,
I'm making of stata program for my RA work.
My final goal is to make this program as stata package like .ado file.
So far, using Mata in my stata program, I finish coding up calculating desiring results.
However, I am stuck on this "already exists" issue.
First, right after running my .do file which includes the stata program and mata function, general commands for my program work well.
However, after entering first command, the second and so forth command keep showing error message: "function_name" already exists.
My code can be simplified as below:
//////////////////////////////////////////////////////////////////
capture program drop myprogram
program myprogram
version 13
local a 3
local b 5
local mataend "end"
di "`a'+`b'"
mata:
mata clear
void myfunc(c,d){
c+d
}
a = `a'
b = `b'
myfunc(a,b)
`mataend'
end
//////////////////////////////////////////////////////////////////
And the result is:
//////////////////////////////////////////////////////////////////
. do "C:\Users\Seongjin\myprogram.do"
. program myprogram
1. version 13
2. local a 3
3. local b 5
4. di "`a'+`b'"
5. local mataend "end"
6.
. mata:
7. mata clear
8. void myfunc(c,d){
9. c+d
10. }
11. a = `a'
12. b = `b'
13. myfunc(a,b)
14. `mataend'
15.
. end
.
.
end of do-file
. myprogram
3+5
8
. myprogram
3+5
myprogram.myfunc() already exists
r(3000);
. myprogram
3+5
myprogram.myfunc() already exists
r(3000);
//////////////////////////////////////////////////////////////////
How can I repeat using the program without running do-file?
Thanks for reading.
I'm making of stata program for my RA work.
My final goal is to make this program as stata package like .ado file.
So far, using Mata in my stata program, I finish coding up calculating desiring results.
However, I am stuck on this "already exists" issue.
First, right after running my .do file which includes the stata program and mata function, general commands for my program work well.
However, after entering first command, the second and so forth command keep showing error message: "function_name" already exists.
My code can be simplified as below:
//////////////////////////////////////////////////////////////////
capture program drop myprogram
program myprogram
version 13
local a 3
local b 5
local mataend "end"
di "`a'+`b'"
mata:
mata clear
void myfunc(c,d){
c+d
}
a = `a'
b = `b'
myfunc(a,b)
`mataend'
end
//////////////////////////////////////////////////////////////////
And the result is:
//////////////////////////////////////////////////////////////////
. do "C:\Users\Seongjin\myprogram.do"
. program myprogram
1. version 13
2. local a 3
3. local b 5
4. di "`a'+`b'"
5. local mataend "end"
6.
. mata:
7. mata clear
8. void myfunc(c,d){
9. c+d
10. }
11. a = `a'
12. b = `b'
13. myfunc(a,b)
14. `mataend'
15.
. end
.
.
end of do-file
. myprogram
3+5
8
. myprogram
3+5
myprogram.myfunc() already exists
r(3000);
. myprogram
3+5
myprogram.myfunc() already exists
r(3000);
//////////////////////////////////////////////////////////////////
How can I repeat using the program without running do-file?
Thanks for reading.
Comment