title: With proc means, how to computed a weighted mean with BY statements?
body: <p>I have the following dataset in SAS:</p>
  
  <pre><code>Obs Date ID Diam frequency 
  1 19736 H-3-10 1.92 1  
  2 19736 H-3-12 1.90 1  
  3 19737 E-2-10 2.92 2  
  4 19737 E-2-10 3.02 2  
  5 19737 E-2-16 2.34 1  
  </code></pre>
  
  <p>I want to have a weighted mean of the variable <code>Diam</code> by <code>Date</code> and <code>ID</code>. Here's my current code:</p>
  
  <pre><code>proc means data= dataset;
      by Date ID;
      var Diam;
      weight frequency;
      output out = m_diam;
  run;
  </code></pre>
  
  <p>The means I obtain are identical if I use or the <code>weight</code> statement or not !
  If I omit the <code>by</code> statement, the weighted and unweighted means are different. But it gives me an overall mean, which is not what I want.
  Thanks for helping.</p>