Let's say I have a Stata dataset that has two variables: type
and price
. The type
value for each observation is a number between 1 and 10.
I want to add a third value that is the average price
of all variables of that type
. So, for example, if the first observation had a type
of 3 and a price
of 10, then I'd like to add a third value that is the average price
of all observations with type
=3.
How can I do this in Stata?