title: Difference between CLASS and By processing in SAS STAT Procs?
body: <p>I am wondering if there is any major difference between using class or by statements in SAS STAT procs.  Take proc means for example.  Suppose we have 2 group/categorical variables, x1 and x2.  I want to compute summary statistics for a variable (x3) for each level combination of x1 and x2.<br>
  For example, using <code>class x1 x2</code> gives me summary stats for x3 at x2=1 at x1=1 and then summary stats for x3 at x2=2 at x1=1, and so on.
  Below is example output.</p>
  
  <pre><code>x1=1 x2=1 x3 mean std
       x2=2 x3 mean std
  x1=2 x2=1 x3 mean std
  ...
  </code></pre>
  
  <p>If I use <code>by x1 x2</code> I get</p>
  
  <pre><code>x1=1 x2=1
  x3 mean std
  (new page)
  x1=1 x2=2
  x3 mean std
  (new page)
  ....
  </code></pre>
  
  <p>If I use <code>class x1</code> and <code>by x2</code> I get</p>
  
  <pre><code>x1=1
  x2=1 x3 mean std
  x2=2 x3 mean std
  x1=2
  x2=1 x3 mean std
  x2=2 x3 mean std
  ......
  </code></pre>
  
  <p>This is some sample data</p>
  
  <pre><code>x1 x2 x3
  1  1  3
  1  1  4
  1  2  6
  1  2  2
  2  1  5
  2  1  1
  2  2  2
  2  2  6
  3  1  10
  3  1  2
  3  2  1
  3  2  8
  </code></pre>
  
  <p>The best I can tell, there is no difference in output, except the manner in which it is displayed.  My example may be too simplistic to show any differences.</p>