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