Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: matrix out


From   Victor Mauricio Herrera <vherrera@wisc.edu>
To   statalist <statalist@hsphsun2.harvard.edu>
Subject   st: matrix out
Date   Sat, 12 Dec 2009 01:08:09 -0600

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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index