title: Stata: using egen group() to create unique identifiers
body: <p>I have a dataset where each row is a <strong>firm, year</strong> pair with a <code>firmid</code> that is a string.</p>
  
  <p>If I do </p>
  
  <pre><code>duplicates drop firmid year, force
  </code></pre>
  
  <p>it doesn't delete anything since there are no duplicates (I originally created the dataset after running <code>duplicates drop firmid year, force</code>).</p>
  
  <p>So far so good.  I want to create a panel which requires a <code>firmid</code> that is numeric.  So I run</p>
  
  <pre><code>egen newid = group(firmid)
  xtset newid year
  </code></pre>
  
  <p>But the 'repeated time values in panel' error pops up.  Moreover,</p>
  
  <pre><code>duplicates list newid year
  </code></pre>
  
  <p>lists a whole bunch of duplicates.</p>
  
  <p>It seems as though <code>egen, group()</code> isn't generating unique groups.  My question is: why, and how do I create unique groups in a robust way?</p>