title: Aggregating Using Proc SQL
body: <p>Suppose I've a dataset in the form:</p>
  
  <pre><code>A B C
  1 3 5
  1 4 8
  1 3 3
  2 2 2
  2 7 6
  2 3 3
  3 4 4 
  3 4 7
  3 2 8
  </code></pre>
  
  <p>Now, I want to take weighted average of each segment of A and then add them up over A. For example in A var for 1, I want to take the weighted avg as (3*5+4*8+3*3)/(3+4+3). And then add up to get 5.6. Same with other 2 segments of A. So, finally the table looks like the following:</p>
  
  <pre><code>A B C   D
  1 3 7 5.6
  2 6 6 7
  3 5 9 8.2
  </code></pre>
  
  <p>Thank you.</p>