Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: RE: Counts of different values in one variable by another variable


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: RE: Counts of different values in one variable by another variable
Date   Thu, 25 Mar 2004 09:50:16 -0500

This approach will not work because personids are not unique within
households -- it will just count total number of records per household, not
the number of unique persons.  Also, the subsequent tabulate command will
count each household multiple times (for each record they have) giving a
wrong answer.

Michael Blasnik
michael.blasnik@verizon.net


----- Original Message ----- 
From: "Ilya Beylin" <ilya.beylin@bateswhite.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, March 25, 2004 9:43 AM
Subject: st: RE: Counts of different values in one variable by another
variable


> Donnel,
>
> Perhaps your question has already been answered.  If not, these lines will
do what you're looking for:
>
> // after this command, dup_flag stores the number of other
> // observations with the same HHID.  Where there is only
> // one unique entry per household ID, dup_flag is set to 0.  Where
> // there are two (e.g. a married couple has been sampled) dup_flag = 1
> // and so on.
>
> duplicates tag HHID, gen(dup_flag)
>
> // to see how many are in each "bin":
> tab dup_flag
>
> // if you want to list/display/browse by bin just type li/di/br if
> // dup_flag == X where X is the bin you wish to list/display/browse
>
>
> I hope this helps,
> Ilya
>


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



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