Hi,
I am wondering whether there are any ways to pass a matrix to a Stata program.
I think the only way is to use option in syntax. But it seems like that option only accepts real scalar and string. I have found a suggestion in the following link (http://www.stata.com/statalist/archi.../msg00311.html). The author suggests that maybe we can use the option and pass the name of the matrix, which is a string, to Stata program. However, I have try that but it seems like that it doesn't work. What follows is my code. I am not sure whether I have made some mistakes or this method doesn't work, since I am a new learner of Stata. Right now I can just define those matrices inside the Stata program, which would make it inconvenient for users to change the contents of the matrices outside the program. Any better idea? Thank you so much!
capture program drop tt8
program tt8,rclass
version 13
syntax , Matt(string)
mat A=(1,2,3,4)
mat B=A+`matt'
return mat B
end
I am wondering whether there are any ways to pass a matrix to a Stata program.
I think the only way is to use option in syntax. But it seems like that option only accepts real scalar and string. I have found a suggestion in the following link (http://www.stata.com/statalist/archi.../msg00311.html). The author suggests that maybe we can use the option and pass the name of the matrix, which is a string, to Stata program. However, I have try that but it seems like that it doesn't work. What follows is my code. I am not sure whether I have made some mistakes or this method doesn't work, since I am a new learner of Stata. Right now I can just define those matrices inside the Stata program, which would make it inconvenient for users to change the contents of the matrices outside the program. Any better idea? Thank you so much!
capture program drop tt8
program tt8,rclass
version 13
syntax , Matt(string)
mat A=(1,2,3,4)
mat B=A+`matt'
return mat B
end
Comment