title: SAS: How to count distinct at multiple levels
body: <p>Is there an elegant way in SAS to calculate a "count distinct" at multiple levels without using a series of sql statements?</p>
  
  <p>Suppose we are counting unique customers. Joe has bought 2 large widgets and 1 small widget, and it is simple enough to count him as 1 customer for large widgets and 1 customer for small widgets. But we also need to count him as only 1 "widget customer", so it requires a separate SQL calculation. And it turns out Joe has also bought a mouse pad, so when we count unique customers for the Miscellaneous Products group we need a third SQL calculation. Joe bought all this stuff from store #1, but when we count the unique customers of miscellaneous products for the Small Store Number Region we also have to account for Joe's purchase of a coffee cup from store #2. Another SQL calculation.</p>
  
  <p>There are many ways in SAS to count things, but it seems there is not a simple way to count "distinct" things. Any suggestions?</p>