title: How to create Sequence number based on two variables together
body: <p>I have the following dataset :</p>
  
  <pre><code> ID   CODE  
   1     A
   1     B  
   2     A  
   2     A  
   2     B  
   3     A  
   3     B  
  </code></pre>
  
  <p>I would like to add a third column to this table which gives a sequence no. as given below :</p>
  
  <pre><code> ID   CODE  SEQ
   1     A     1
   1     B     2
   2     A     1
   2     A     1
   2     B     2
   3     A     1
   3     B     2
  </code></pre>
  
  <p>How can I achieve this instead of coding A as 1 and B as 2 rather by a retain statement ?</p>