sacrificial lamb
sysuse auto,clear
drop if rep78==.
egen avgprice = mean(price),by(rep78)
bys rep78: gen byte want= (_n==1)
mkmat rep78 avgprice if want,matrix(tom)
mat list tom
Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html
On Sep 14, 2006, at 2:33 AM, Tom wrote:
Assume my "varlist" contains variables like invest, market and stock.
The task is to create a matrix that contains for each panel unit (i.e.
company) the means of the varibales in `varlist' over the time
periods. What my program does:
qui collapse (mean) `varlist', by("`pvar'") fast
qui mkmat `varlist', matrix(`X')
Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics with Stata:
http://stata-press.com/books/imeus.html
*
* 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/