title: Counting the repeated values of a variable by id
body: <p>I am at my very first steps with SAS, and I incurred into the following problem which I am not able to solve.</p>
  
  <p>Suppose my dataset is:</p>
  
  <pre><code>data dat;
    input id score gender;
    cards;
    1 10 1
    1 10 1
    1 9 1
    1 9 1
    1 9 1
    1 8 1
    2 9 2
    2 8 2
    2 9 2
    2 9 2
    2 10 2
    ;
  run;
  </code></pre>
  
  <p>What I need to do is to count the number of times the <code>score</code> variable takes values 8, 9 and 10 by id. Then to create the newly variables <code>count8</code>, <code>count9</code> and <code>count10</code> such that I can get the following output:</p>
  
  <pre><code>  id     gender    count8    count9    count10
     1        1         1          3        2
     2        2         1          3        1  
  </code></pre>
  
  <p>How would you suggest ot proceed? Any help would be greatly appreciated.</p>