I have a table with the columns Department_ID and Person_ID and Salary (among other columns). I want to calculate the average salary of the departments and save it in a new column "ave_Salary". There are sometimes multiple observation with the same Person_ID. How to calculate ave_Salary (i.e. as if Person_ID never repeats) without dropping all other columns?
I think the following is the code but I am not sure:
bys Department_ID (Person_ID): egen ave_Salary= mean(Salary)
Thank you very much for your help.
I think the following is the code but I am not sure:
bys Department_ID (Person_ID): egen ave_Salary= mean(Salary)
Thank you very much for your help.
Comment