[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: counting members of groups in unbalanced panel data

From   "Martin Weiss" <>
To   <>
Subject   st: AW: counting members of groups in unbalanced panel data
Date   Fri, 2 Oct 2009 16:54:09 +0200


-bysort- is always a good place to start for this sort of problem, but you
also want to have a look at -collapse- and -contract-


-----Ursprüngliche Nachricht-----
[] Im Auftrag von Oliver
Gesendet: Freitag, 2. Oktober 2009 16:49
Betreff: st: counting members of groups in unbalanced panel data

Hello everyone

I am having troubles figuring out how to in a panel data structure to derive
some descriptives.

In my data

- there are mutliple companies, each having 1 to many funds
- each fund being of one of 11 strategies
- each fund only showing observations for part of the total sample period.

I require

- the total number of companies per month
- the average (median, max) number of funds per company per month
- the average (median, min, max) number of strategies per company per month 

The data format is for example like this:

CompanyID      FundID             Strategy           Date             Return
3021                 205                  2          Jan 94             X
3021                 205                  2          Feb 94             X
3021                 405                  3          Jan 94             X
4671                 904                  9          Feb 94             X
4671                 904                  5          Mar 94             X
4671                 154                  1          Mar 94             X

Number of funds per family per month was easy:
by companyid mydate ,sort: egen perfamnrofunds = count(R)

But now I ran into troubles. I would greatly appreciate if anyone could

Thanks in advance,

Best regards,


*   For searches and help try:

*   For searches and help try:

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