Dear all
I'm having a problem when I run a Stata command constructed in Mata. Here is an example (that is not my original code, but that uses the same logic).
************************
mata
var=("x1","x2","x3")
for (v=1;v<=cols(var);v++) {
cmd="reg y "+var[1,v]
st_local("cmd",cmd)
stata("`cmd'")
stata("di `cmd'")
}
end
***********************
This should work, but it didn't. Actually this works when I do by myself, but it didn't when I use a loop.
The "local" just is not transferred to Stata.
Why? Can someone help-me to make it work.
Thanks in advance
I'm having a problem when I run a Stata command constructed in Mata. Here is an example (that is not my original code, but that uses the same logic).
************************
mata
var=("x1","x2","x3")
for (v=1;v<=cols(var);v++) {
cmd="reg y "+var[1,v]
st_local("cmd",cmd)
stata("`cmd'")
stata("di `cmd'")
}
end
***********************
This should work, but it didn't. Actually this works when I do by myself, but it didn't when I use a loop.
The "local" just is not transferred to Stata.
Why? Can someone help-me to make it work.
Thanks in advance
Comment