Array

Good morning Stata Family,

Please I want to create a new variable for the average wage earned by each worker for B and C shifts alone (as seen in the image above).

The code that I know: egen avgwage = mean(wage), by workerid gives me the average wage using all the shifts. I just want to find the average for just the B & C shifts, which I intend to use as a control for my analysis.

Any guidance you can provide will be most appreciated.

Thank you!