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

st: how to generate groups based on some characteristics and obtain the mean/median value for each group

From   "Yi, Bingsheng" <>
Subject   st: how to generate groups based on some characteristics and obtain the mean/median value for each group
Date   Tue, 18 Jun 2002 19:11:01 -0400

Dear Statalisters,

I wonder whether you will help me figure out the codes to solve the
following problem:

I have  12 years panel data containing these four variables: Tobin's q,
size, 4-digit industry code (ind4), and id. For each year, I want to make
some adjusments in one variable (Tobin's q) based on the other two variables
(industry and size). First I need to ensure that there are lat least 10
firms within each industry. If the number of firms within a 4-digit industry
code is less than 10, I use 3-digit industry code generated by gen str4
ind3=substr(ind4,1,3), see whether the number of firms with the same 3-digit
industry code is greater or equal to 10, if not, then generate and use
2-digit  industry code. So in the end there are at least 10 firms within an
industry ( which are classified by 4-digit, 3-digit, 2-digit, or 1-digit
industry code). The  problem is how to get and record the number of firms in
each industry.

Then within each industry, I want  classify firms into three groups based on
size, the smallest group contains the smallest 30% firms in size within that
industry, the middle group contains the middle 40% firms in size (30% to
70%), and the large group contain firms whose size belongs to the largest
30% in that industry. Then I get the median or mean value of Tobin's q for
each of these groups within an industry. 

the industry-size adjusted Tobin's q = Tobin's q of a firm in an industry -
the mean tobin's q of a group to which the firm belongs within the same

For example, if IBM belongs to the largest size group in computer industry,
then the industry-size adjusted Tobin's q of IBM is equal to 
Tobin's q of IBM - the mean/median value of the largest size group within
the computer industry.

But I don't know how to generate these groups and obtain the industry-size
adjusted Tobin's q for a sample firm. I will greatly appreciate your help!!!



*   For searches and help try:

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