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

st: RE: a little help


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: a little help
Date   Wed, 5 Feb 2003 17:48:29 -0000

Rodrigo Briceņo

> I need to calculate how many households have at less one
> member insured with
> the public sector. I calculated a number if the household
> have at less a
> member insured. But I don't know how to calculate the
> number of households
> that have one or more members insured. For example:
>
> HH   SS1 SS1inHH
> 1       .       1
> 1       .       1
> 1       1      1
> 1       .       1
> 2       1      2
> 2       2      2
> 3       .       0
> 3       .       0
>
> How can I calculate that only 2 households have at least
> one member insured?

One way to approach this is through -egen, tag()-.
The manual gives guidance at [R] egen.

I guess what preceded this is something like

. bysort HH : egen SS1inHH = count(SS1)

Thus by construction all values of
SS1inHH are identical within HH. Therefore if we
want to count over households, we should
count just one value in each household.

For this,

. egen tag = tag(HH)
. tab SS1inHH if tag

Another use of -egen, tag()- is this:
suppose you want a plot of group sd
versus group mean.

. by group: egen sd = sd(myvar)
. by group: egen mean = mean(myvar)

All values are identical within
each group, so many data points would
be overlaid.

Another way to do it is

. egen tag = tag(group)
. scatter sd mean if tag

Nick
n.j.cox@durham.ac.uk

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