title: Reshape Dataset Long to Wide
body: <p>I thought I understood how to use <code>proc transpose</code> but I seem to be missing something here:</p>
  
  <p>Have:</p>
  
  <pre><code>fam pay quarter
  1   100 7
  2   20  7
  3   34  7
  2   54  8
  3   64  8
  1   36  9
  </code></pre>
  
  <p>Want:</p>
  
  <pre><code>fam qtr_7   qtr_8   qtr_9
  1   100       0      36
  2   20       54       0
  3   34       64       0
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>proc transpose data=have out=want prefix=qtr_;
  by fam;
  id quarter
  var pay;
  run;
  </code></pre>
  
  <p>I keep getting an error message that "The ID value _7 is observed twice"</p>
  
  <p>As a backdoor way into this, I tried:</p>
  
  <pre><code>data want;
      set have;
          if quarter = 1 then qtr1 = pay;
              else if quarter = 2 then qtr2 = pay;
              else if quarter = 3 then qtr3 = pay;
              else if quarter = 4 then qtr4 = pay;
              else if quarter = 5 then qtr5 = pay;
              else if quarter = 6 then qtr6 = pay;
              else if quarter = 7 then qtr7 = pay;
              else if quarter = 8 then qtr8 = pay;
              else if quarter = 9 then qtr9 = pay;
              else if quarter = 10 then qtr10 = pay;
              else if quarter = 11 then qtr11 = pay;
  run;
  </code></pre>
  
  <p>But, I would still need to collapse the rows, which I can't figure out how to do.</p>
  
  <p>Thanks for any help.</p>