title: SAS PROC TABULATE percentages by multiple class variables with missing values
body: <p>I would like to create a table that has three variables where var2 is a percentage of var1 and var3 is a percentage of var 2, broken down by class variables that have missing values. </p>
  
  <p>To explain, imagine I have data showing who applied, was interviewed, and was hired for a job, e.g. </p>
  
  <pre><code>data job; 
  input applied interviewed hired; 
  datalines; 
  1   1   1
  1   1   1
  1   1   1
  1   1   0
  1   1   0
  1   1   0
  1   0   .
  1   0   .
  1   0   .
  1   0   .
  ; 
  run; 
  </code></pre>
  
  <p>it's very easy to create a table that shows the count of who applied, and then the percentage of those who were interviewed and then of those people, the percentage who was hired. </p>
  
  <pre><code>proc tabulate data = job; 
  var applied interviewed hired; 
  tables applied * n (interviewed hired) * mean * f=percent6.; 
  run; 
  </code></pre>
  
  <p>which gives: </p>
  
  <pre><code>applied interviewed hired 
     10        60%     50% 
  </code></pre>
  
  <p>Now I would like to break that down by several class variables with missing values. </p>
  
  <pre><code>data have; 
  input sex degree exp applied interviewed hired; 
  datalines; 
  0   1   1   1   1   1
  1   .   0   1   1   1
  .   0   1   1   1   1
  0   1   0   1   1   0
  1   0   1   1   1   0
  0   1   0   1   1   0
  1   .   1   1   0   .
  0   1   .   1   0   .
  .   0   0   1   0   .
  1   0   0   1   0   .
  ; 
  run; 
  </code></pre>
  
  <p>If I do one class variable at a time it will give me the correct percentages: </p>
  
  <pre><code>proc tabulate data = have format = 6.; 
      class sex; 
      var applied interviewed hired; 
      tables sex, applied * sum (interviewed hired) * mean * f=percent6.; 
  run; 
  </code></pre>
  
  <p>Is there a way to do all three class variables in the table at once and get the right percentage for each category. so the table looks like: </p>
  
  <pre><code>       applied  interviewed  hired
  sex 
    0       4        75%       33%
    1       4        50%       50%
  degree  
    0       4        50%       50%
    1       4        75%       33%
  exp 
    0       5        60%       33%
    1       4        75%       67%
  </code></pre>
  
  <p>This is something I must do many, many times and I need to populate tables in a report with the numbers, so I'm looking for a solution where the table can be printed all in one step. </p>
  
  <p>How would you solve this problem? </p>