title: SAS: assign serial number based on the group
body: <p>I know there are similar questions regarding serial numbers but my case is a little different.
  I need to assign serial number based on the group variable. Now, I have my data sorted by the group variable. The following data is just a part of the whole dataset. Basically, I want to create "serial_num" variable that assign unique serial number by the group as shown below.</p>
  
  <p>For example, when group = 1, each has own unique serial number. When group = 2, there are two identical serial numbers. I hope you guys get the pattern by observing the data below.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>serial_num  group
  ----------------
  1           1
  2           1
  .           .
  .           .
  .           .
  7           2
  7           2
  8           2
  8           2
  .           .
  .           .
  .           .    
  10          3
  10          3
  10          3
  11          3
  11          3
  11          3
  .           .
  .           .
  .           .
  </code></pre>