Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: finding number of unique values of a variable


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: finding number of unique values of a variable
Date   Sun, 17 Aug 2008 17:00:40 -0400

< >
Dick said

I would like to loop over the list of variables in a data set and
find the number of unique values for each variable, regardless
of whether the variable is numeric or string. There are several
ways to do this for a numeric variable, but I don't see a convenient
way to do it for a mixture of string and numeric variables.


I am frequently reminded by Nick Cox that when I say unique I mean distinct. If you -findit distinct- you will locate some of his pearls of wisdom:

http://www.stata.com/support/faqs/data/distinct.html
http://www.stata.com/support/faqs/data/distinctstrings.html

which may be helpful. Also referenced are some of his Speaking Stata columns in the Stata Journal, which are freely downloadable through mid-2005.

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index