I have a dataset where each observation (row) is a person. I then have data on their education degree and the company they work in. The data is complicated by the fact, that some persons work in several different companies. From this dataset I want to create a dataset where each observation (row) is a company and then have a variable showing the percentage of persons working in the company, who has a university degree.
In the data below, the person has university degree, if education takes the value 3. My data looks something like this:
And the data that I would want to end up with would look something like this:
I am pretty sure my solution contains some -egen function, followed by a -collapse, but can't figure the -egen part out. Any help would be much appreciated!
In the data below, the person has university degree, if education takes the value 3. My data looks something like this:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(company person education) 1 1 1 1 2 2 1 3 1 2 4 1 2 5 2 2 6 3 2 7 3 3 8 1 3 9 3 4 9 3 4 10 2 4 10 2 5 9 3 5 10 2 5 11 1 5 12 2 end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte company str4 share_uni 1 "0" 2 "0,5" 3 "0,5" 4 "0,33" 5 "0" end

Comment