[email protected]
>
> Yesterday night, I encounter this problem. I have the
> following table:
>
> . ta senum rich3
>
> Enumeratio | rich3
> n Area | 1 2 3 | Total
> -----------+---------------------------------+----------
> 1 | 45 31 26 | 102
> 2 | 13 10 6 | 29
> 3 | 40 18 4 | 62
> 5 | 11 13 20 | 44
> 2171 | 0 10 1 | 11
> 2455 | 0 0 11 | 11
> 2920 | 0 11 0 | 11
> 3052 | 0 1 10 | 11
> 4163 | 0 9 3 | 12
> -----------+---------------------------------+----------
> Total | 2091 2085 931 | 5107
>
> I am interessed in the first column (very poor). I want to
> compute the ratios
> of poor in the psu
> (for example for the first line: (45 /102 )*100 , for the
> second line: (13 /29)
> *100, etc...)
> and group the PSUs into 3 categories: 40% of poor, 60% of
> poor and more than
> 80% of poor.
>
> I use the command:
> tab senum rich3, matcell(mat_1)
>
> to retrive the matrix but I don't know how to retrive the vector.
>
> I just copy the table into Excel to compute my ratios.
>
> Is there any way to proceed in stata?
If you proceed this way, you end up having
to do an elementwise division of vectors;
that's possible (-search matewd-) but awkward; and then
you have to map your results back onto the dataset.
Here is another way:
egen vpoor = sum(100 * (rich3 == 1)/_N), by(senum)
Watch out, however, for missings.
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/