Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Tab and Matcell

From   "Fraser, Steven" <>
To   "Statalist (E-mail)" <>
Subject   st: Tab and Matcell
Date   Thu, 13 Jun 2002 09:48:59 -0400

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:

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