Friedrich said
sysuse auto, clear
local i = 1
foreach var of varlist price mpg weight {
quietly tabstat `var', stat(mean sd) by(foreign) save
tabstatmat mat
if `i'==1 {
matrix bigmat = mat
}
else {
matrix bigmat = bigmat \ mat
}
local i = `i' + 1
}
But that wheel has already been invented...
sysuse auto, clear
local vars price mpg weight
mat res1 = J(2,2,0)
local i 0
foreach v of local vars {
qui statsmat `v', stat(mean sd) by(foreign) mat(res`++i')
if `i'>1 {
mat res1 = res1 \ res`i'
}
}
mat list res1
Kit
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/