Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65569

egen

$
0
0
Dear Statalisters,
Below I present a few observation of a panel data set. The data is organized by firm and year. Within each firm year, the firm could have multiple patents, these patents have a classification id (patentclassid), e.g. firmid=1000, has 3 patents, 2 of them are in the same class (id=200).

I want to generate a mean value – a count of the average number of patent for each year and patentclass.


e.g. in year 1990, patentclassid, firm 1000 has 2 patents in this class, and firm 1001 has 1 patent in this class, so the mean is (2+1)/2=1.5



Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(firmid patentclassid year)
1000 200 1990
1000 200 1990
1000 201 1990
1001 200 1990
1001 201 1990
1001 201 1990
1002 201 1990
1002 202 1990
end

I thought of using

bysort year patentclassid: egen

But not sure what follows egen,

Thank you,
Rochelle



Viewing all articles
Browse latest Browse all 65569

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>