I have a set of data sort of like:
What I want to do, is generate another variable, `gap', that is the mean(WeekWage) if sex == 1 - mean(WeekWage) if sex ==0 for every occupation.
So, here is what I tried:
And the error I get is:
Sex | WeekWage | Occupation |
0 | 823 | Fishing |
1 | 917 | Hunting |
0 | 426 | Officeing |
So, here is what I tried:
Code:
by occupation, sort: egen gap = mean(WeekWage) if sex == 1 - mean(WeekWage) if sex ==0
Code:
unknown function mean()
Comment