# st: how to generate groups based on some characteristics,obtain the m ean/median value for each group, and assign a sample into the correct gro up

 From "Yi, Bingsheng" To "'statalist@hsphsun2.harvard.edu'" Subject st: how to generate groups based on some characteristics,obtain the m ean/median value for each group, and assign a sample into the correct gro up Date Thu, 20 Jun 2002 15:07:18 -0400

```Special thanks to P. Seed, N. Winter and N. Cox!!! Thank you so much!!!

I'm sorry that I didin't make my problem clearer. Supposes the 10 firms (obs
1-10)have the same ind4 as 1041, I will consider them to belong to industry
1041. But as to firm 11, there is only one firm  in its 4-digit ind code
1044, I will consider it belong to industry 104, which will contain all the
11 firms with the same ind3, 104. In other words, firm 1-10 belong to
industry 1041 and industry 104 simultaneously.

obs Tobin's q ind4 ind3 ind2 ind1 industry  size grp-under-ind4
grp-under-ind3 mean-of-grp
1             1041 104  10   1       1041    1   small            ?
2             1041 104  10   1       1041    3   small            ?
3             1041 104  10   1       1041    2   small            ?
4             1041 104  10   1       1041    5   middle           ?
5             1041 104  10   1       1041    4   middle           ?
6             1041 104  10   1       1041    9   large            ?
7             1041 104  10   1       1041    8   middle           ?
8             1041 104  10   1       1041    11  large            ?
9             1041 104  10   1       1041    10  large            ?
10            1041 104  10   1       1041    7   middle           ?
11            1044 104  10   1       104     6     N.A.           ?

Subsequently I will subdivide firms in each industry into small, middel and
large groups according to firm size. The small group contains the smallest
30% firms in size within an 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. How I can subdivide firms
according to size in an industry and assign a firm to a group according to
its size? I also need to get the median or mean value of Tobin's q for each
of these groups within an industry.

For industry 1041, there are 10 firms, firm 1 through 10, and  For indutry
104, there are 11 firms. Take firm 1 as an example, according to its size,
it belongs to samll group under ind4 as 1041. Firm 1's industry-size
adjusted Tobin's q = firm 1's Tobin'q - the mean Tobin's q of small group
under ind4. As to firm 11, first I need to assign firm 11 into a group under
ind3 of 104 according to its size (industry 104  contain all the 11 firms, a
firm can belong to different groups under different industry codes), then I
have to get the mean value of Tobin's q of firms in the same group as firm
11.

I hope that you will understand my problems now and help me out, I really

Bing

*
*   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/
*
*   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/
```