Hello everyone,
I am currently working on my bachelor thesis and have question regarding the generating of a new variable.
In my data set I have player that produce an output.
I wann to generate a variable that gives me an average output. This average should include only obersavtions with the same team and year as the player but shouldn't take the observations of the player itself.
So I want the average: H/AB
This is as far as I have come:
gen teamsBA = H/AB if ((teamID == teamID) & (yearID == yearID))
Obviously excluding H and AB of that player is not accounted for
Thank you in advance for looking at this and I am happy to hear about any idea you have to solve my problem.
I am currently working on my bachelor thesis and have question regarding the generating of a new variable.
In my data set I have player that produce an output.
I wann to generate a variable that gives me an average output. This average should include only obersavtions with the same team and year as the player but shouldn't take the observations of the player itself.
So I want the average: H/AB
This is as far as I have come:
gen teamsBA = H/AB if ((teamID == teamID) & (yearID == yearID))
Obviously excluding H and AB of that player is not accounted for
Thank you in advance for looking at this and I am happy to hear about any idea you have to solve my problem.
Comment