Dear Statalist:
I am having a problem implementing matrix operations within the 'tab'
command.  Using a variation of the familiar car example, assume I have the
following dataset:
Manuf		Model		Class		MPG
ford		explorer		SUV		12
ford		expedition	SUV		10
ford		focus		compact	34
dodge		durango		SUV		16
gm		tahoe		SUV		15
Assume I have hundreds of automobiles (cars, trucks, and SUVs).  I am trying
to develop a focus measure (a Herfandahl index) that captures the focus of
the manufacturer.  For example, GM (with all the GM lines) would probably
have a lower focus measure, while Volkswagon, which doesn't make any trucks
or SUVs, would have a higher focus measure.  What I need is the frequency of
each class which will be different for each manufacturer.
My approach has been
sort manuf
by manuf: tab class, matcell(classmat)
mat list classmat
Part 1 of my question:  The resulting matrix is only for the last 'manuf'.
It will not allow "by:"  Can I incorporate as part of a loop?
Part 2 of my question:  I then need to access the variables and perform
calculations.  Would it be possible to put all the results in one matrix?
Thanks for the assist..SF
Steve Fraser
Univ of South Florida
*
*   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/