Thanks to Kit Baum, a -levels- program is now
available from SSC.
-levels- displays a sorted list of the distinct values of varname,
which should be a variable taking on integer or string values, or in
other words, a categorical variable, very broadly so defined.
It may be useful when it is desired to cycle through the
distinct values of varname with (say) -foreach-. -levels-
leaves behind a list in r(levels) which may be used in a
subsequent command. Optionally, the list may be inserted
as a local macro within the calling program's space.
-levels- is considered to be -vallist- (STB-60, same author) done
better.
Stata 7 is required.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/