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
[email protected]
*
* 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/