Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Count observations


From   "Feiveson, Alan H. (JSC-SK311)" <alan.h.feiveson@nasa.gov>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Count observations
Date   Thu, 27 Jun 2013 12:34:56 -0500

Another simple way is 

qui tab auto
di r(r)

Al Feiveson

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Thursday, June 27, 2013 12:23 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Count observations

There was a review of this area in

http://www.stata-journal.com/sjpdf.html?articlenum=dm0042

The article discusses several ways to approach the question, including the program -distinct-, which you could download from the Stata Journal site. (-search distinct- first.)

. sysuse auto
(1978 Automobile Data)

. distinct

              |        Observations
              |      total   distinct
--------------+----------------------
         make |         74         74
        price |         74         74
          mpg |         74         21
        rep78 |         69          5
     headroom |         74          8
        trunk |         74         18
       weight |         74         64
       length |         74         47
         turn |         74         18
 displacement |         74         31
   gear_ratio |         74         36
      foreign |         74          2
Nick
njcoxstata@gmail.com


On 27 June 2013 18:13, Miguel Angel Duran Munoz <maduran@uma.es> wrote:
> Hi, Statalisters. I have a doubt that must have a very simple 
> solution, but I have not been able to find it. I have a variable where 
> some numbers appear more than once. And I would like to know the 
> number of different numbers; ie,  variable = 1 1 1 2 3 4 4 4..., so 
> there are 4 different numbers.
>
> Thanks in advance.
>
> Miguel.
>
> *
> *   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/

*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index