Count unique values in Stata
<p><code>codebook</code> is a great command in Stata. It describes data contents but also simply identifies unique values</p>

<pre><code>sysuse auto, clear
codebook mpg, compact
</code></pre>

<p>Number of unique values of mpg is 21. Looking at the help of the command, it does not seem possible to store this value. Am I wrong?</p>

<p>I am aware of other ways to compute the <a href="http://www.stata.com/support/faqs/data-management/number-of-distinct-observations/" rel="noreferrer">number of unique values</a> in Stata, but it would be so convenient to add this feature to the <code>codebook</code> command.</p>