Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | László Sándor <sandorl@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: the fastest way to check if unique values of a variable > 100 |
Date | Sun, 25 Aug 2013 18:33:18 -0400 |
Thanks, I think I am with Daniel that oldish ado code would hardly be competitive, I did not even test. Assert is fun, as always, if only I could assume that the values are always natural numbers starting at 0. Thanks! On Sun, Aug 25, 2013 at 4:43 PM, daniel klein <klein.daniel.81@gmail.com> wrote: > Guess user-written approaches (or ados in general) are probably slower > than built-in commands like -tabulate-. I would go with -assert- > > cap as foo > 100 ,f > > > Note that -capture- supresses output by default, so -quietly- is not needed. > > Best > Daniel > > -- > > Try -unique- or -distinct- from SSC. > > On Sun, Aug 25, 2013 at 11:18 AM, László Sándor <sandorl@gmail.com> wrote: >> Hi, >> Currently I think it is worth a quiet -cap tab- to catch the error >> r(134) or r(r). But it still can be a wasteful operation, as tabbing >> does work for many thousands of observations. And of course it does >> more than simply count the unique values. >>[...] >> Is there a fast approach I am not aware of? > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/