title: how to generate a new variable with loops
body: <p>I'd like to generate a dummy that contains certain characteristics.</p>
  
  <pre><code>mgr firm enterdate leavedate newdummy
  A    x      1        3          .
  B    x      3        5          1
  C    x      6        15         1
  D    x      8        15         0
  E    x      9        15         0
  </code></pre>
  
  <p>If all managers enter before this manager have a leavedate smaller than the current enterdate, the dummy equals one.</p>