P_ID | Firm_ID | year | trainee_or_employed | wage | Average_wage_of_training_years | Firm_fixed_effect | Firm_fixed_effect_last_year_of_training | Firm_size | Firm_size_last_year_of_training |
1 | 1111 | 2011 | 1(trainee) | 800 | 850 | -.34 | -.34 | 50 | 54 |
1 | 1111 | 2012 | 1 | 900 | 850 | -.34 | -.34 | 54 | 54 |
1 | 1111 | 2013 | 2 (employed) | 2500 | 850 | -.34 | -.34 | 52 | 54 |
1 | 1111 | 2014 | 2 | 2600 | 850 | -.34 | -.34 | 57 | 54 |
2 | 3333 | 2011 | 1 | 600 | 716.6 | .523 | .822 | 123 | 161 |
2 | 4444 | 2012 | 1 | 700 | 716.6 | .822 | .822 | 152 | 161 |
2 | 4444 | 2013 | 1 | 850 | 716.6 | .822 | .822 | 161 | 161 |
2 | 5555 | 2014 | 2 | 2700 | 716.6 | 1.04 | .822 | 236 | 161 |
2 | 5555 | 2015 | 2 | 2800 | 716.6 | 1.04 | .822 | 254 | 161 |
2 | 5555 | 2016 | 2 | 3000 | 716.6 | 1.04 | .822 | 250 | 161 |
I have such a dataset and need to create some new variables conditioned on some other variables and got confused.
1. Creating variable "Average_wage_of_training_years" from the person's trainee years? Such a similar thing I should write?
bys year: gen Average_wage_of_training_years=mean(wage) if trainee_or_employed==1
2. Creating the variable "Firm_size_last_year_of_training" by using the person's firm in the last training year?
Would you please help me with these two commands?
Best,
Alp
Comment