title: Changing ID from nth to last row if something happens at nth row
body: <p>My data has some problem. The survey is conducted on housing unit. So the two rows with the same person ID might not actually indicate the same person. </p>
  
  <p>I want to assign different ID for actually different person.</p>
  
  <p>Let's say I have this data.</p>
  
  <pre><code>id  yearmonth  age 
  1   200001      12
  1   200002      12
  1   200003      14
  1   200004      14
  1   200005      14
  </code></pre>
  
  <p>3rd row is definitely different person. Its age increase by 2. </p>
  
  <p>So I want to change ID like</p>
  
  <pre><code>id  yearmonth  age 
  1   200001      12
  1   200002      12
  10   200003      14
  10   200004      14
  10   200005      14
  </code></pre>
  
  <p>How can I do this? I think I can change the ID of 3rd row by writing</p>
  
  <pre><code>bysort id (yearmonth): replace id=id*10 if age[_n-1]&gt;age+1 | age[_n-1]+1&lt;age
  
  (where I multiply by 10 because all IDs have the same number of numbers, so that multiplying by 10 won't give any duplicate)
  </code></pre>
  
  <p>But how can I change all subsequent rows?</p>