Hi all,
I am working on my MSc. Thesis and there is a command that I do not know how to create. Basically my problem is as follows:
BACKGROUND:
I have employee-level data, and I need to collapse it into firm-level data, in order to merge it with some firm-level financial variables. My (simplified) data looks like this:
Where Gender is a dummy (0 for male employee, 1 for female employee).
Please note that every company has a different number of employees.
The data that I need after collapsing is as follows:
Basically, I need to collapse while doing the following calculation:
collapse (mean) NumberOfJobs , by(CompanyID, Year)
list, clean
But this code gives me the average of all employees in the company, irrespective of their gender.
Could this be done?
Thank you in advance!
I am working on my MSc. Thesis and there is a command that I do not know how to create. Basically my problem is as follows:
BACKGROUND:
I have employee-level data, and I need to collapse it into firm-level data, in order to merge it with some firm-level financial variables. My (simplified) data looks like this:
Employee | Gender | CompanyID | Year | NumberOfJobs |
A | 1 | 1 | 2.000 | 3 |
A | 1 | 1 | 2.001 | 2 |
B | 1 | 1 | 2.000 | 2 |
B | 1 | 1 | 2.001 | 1 |
C | 0 | 2 | 2.000 | 1 |
C | 0 | 2 | 2.001 | 2 |
Please note that every company has a different number of employees.
The data that I need after collapsing is as follows:
CompanyID | Year | MultiemployedFemales |
1 | 2.000 | 1 |
1 | 2.001 | 1 |
2 | 2.000 | 0 |
2 | 2.001 | 0 |
- Under the new variable MultiemployedFemales (I gave it a random name, it can be any) I need the average number of simultaneous jobs that the female employees have in each company. So, only the average of the female employees, ignoring the male employees.
- In the first line of the second table, it would be calculated as: 2/2 =1, because the 2 employees at firm 1 are female.
collapse (mean) NumberOfJobs , by(CompanyID, Year)
list, clean
But this code gives me the average of all employees in the company, irrespective of their gender.
Could this be done?
Thank you in advance!
Comment