Consider the following panel dataset:
I am running the following regression:
After this regression, I would like to count distinct affiliation and ids in and out of my regression sample, and this is my code:
My understanding is that the "max" of the -sum- gives you the distinct counts for each variable of my interest.
I am running several regressions (approx. 30), but after each regression, I would like to store the "max" number from the sum and export to Excel as csv or xlsx file.
Do you know what is the best way to go about doing this?
id | datadate | affiliation | revenue | workforce |
100 | 31-May-01 | NBA | 200 | 11 |
100 | 31-May-02 | NBA | 250 | 15 |
101 | 31-May-03 | NHL | 900 | 20 |
101 | 31-May-01 | NFL | 932 | 9 |
102 | 31-May-02 | NHL | 400 | 65 |
103 | 31-May-03 | FIFA | 230 | 25 |
103 | 31-May-04 | FIFA | 890 | 28 |
Code:
reg revenue workforce
Code:
egen distinct_id = group(id) if e(sample) egen distinct_affiliation = group(affiliation) if e(sample) sum distinct_id distinct_affiliation
I am running several regressions (approx. 30), but after each regression, I would like to store the "max" number from the sum and export to Excel as csv or xlsx file.
Do you know what is the best way to go about doing this?
Comment