Hello, I'm trying to obtain a matrix using the following code:
*********************************************
local varlist "strokeriskNULL strokeriskP55"
matrix out = J(20,3,-99)
matrix colnames out = risk sex age
matrix rownames out = `varlist'
local irow = 0
foreach var in `varlist' {
foreach i in 2 3 4 5 6 {
foreach s in 0 1 {
local ++irow
qui mim, storebv: svy: regress `var' if sex==`s' & ageg==`i'
matrix A=e(b)
matrix out[`irow',1]=A[1,1]
matrix out[`irow',2]=`s'
matrix out[`irow',3]=`i'
}
}
}
matrix list out
*******************
I expect to get ten lines starting with "strokeriskNULL" and ten starting with "strokeriskP55". However I get only the first line starting with "strokeriskNULL" and the remaining 19 starting with "strokeriskP55".
Could anybody point me to what's wrong with these instructions?
Very thankful,
Mauricio Herrera.
*
* 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/