Statalist


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

Re: st: Command to identify number of unique individuals


From   "Martin Weiss" <Martin.Weiss1@gmx.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Command to identify number of unique individuals
Date   Mon, 28 Dec 2009 19:45:40 +0100

<>

See the tips by Nick and coauthor here: http://www.stata.com/support/faqs/data/distinct.html


For instance:

***
clear*
set obs 2000
gen id=_n
bys id: gen byte first =_n==1
cou if first
//now only 1999 unique
clear*
set obs 2000
gen id=_n
replace id=2 in 3
bys id: gen byte first =_n==1
cou if first
***

HTH
Martin
-------- Original-Nachricht --------
> Datum: Mon, 28 Dec 2009 12:05:41 -0600
> Von: "Weichle, Thomas" <Thomas.Weichle@va.gov>
> An: statalist@hsphsun2.harvard.edu
> Betreff: st: Command to identify number of unique individuals

> Hi Statalisters,
> Is there a command that will list the number of unique individuals in my
> dataset?  I'm familiar with the duplicates and dups commands, but these
> aren't showing me the number of unique individuals.
> It should be equivalent to the following SAS command which will identify
> the number of unique observations by study_id:
> 
> PROC SORT NODUPKEY DATA=test;
> BY study_id;
> RUN;
> 
> Tom Weichle
> Math Statistician
> Center for Management of Complex Chronic Care (CMC3)
> Hines VA Hospital, Bldg 1, C202
> 708-202-8387 ext. 24261
> Thomas.Weichle@va.gov 
> 
> *
> *   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/

-- 
Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
http://portal.gmx.net/de/go/dsl02
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index