[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
rraciborski@gmail.com |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Code |

Date |
Tue, 22 Jul 2008 16:05:23 -0400 |

this will take care of multiple incomes of the same value ***************************** start of poverty.ado ************************ *! program to calculate mean income around a given poverty level *! syntax: poverty incomeVar povertyLevel window *! example: poverty gdppc 12000 500 program define poverty, sortpreserve version 9.2 args inc inclev n /* inc = income variable inclev = poverty level (number) n = window (how many incomes above and below poverty level to include) */ tempvar diff match id sort `inc' gen `id' = _n gen byte `match' = 0 gen `diff' = abs(`inc' - `inclev') qui summ `diff' qui replace `match' = 1 if `diff' == r(min) qui count if `match'==1 if r(N) > 1 { di di as res "Note: More than one income matches the poverty level of `inclev'" } qui summ `id' if `match' == 1 local min = r(min) local max = r(max) if (`min' - `n' <= 0) | (`max' + `n' > _N) { di as err "There are not enough observations around the poverty level" exit } di di as res "Summary of income for households above and below the poverty level of `inclev'" summ `inc' if (_n >= `min' - `n') & (_n <= `max' + `n') end exit ***************************** end of poverty.ado ************************ On 7/22/08, Sergiy Radyakin <serjradyakin@gmail.com> wrote: > Dear Ana, > > probably something like this to get started: > > sysuse auto, clear > sort price > local price_line=5079 /* 228.22 */ > local window=5 > tempvar obsnum > gen `obsnum'=_n > sum `obsnum' if price==`price_line' > sum price in `=`=r(min)'-`window''/`=`=r(max)'+`window'' > > Note that there might be more than 1 household right at the level of > poverty line. The above code will take all of them, plus window > households on the sides > > Also note that a concept of "being at the poverty line" sounds > strange. Typically there are poor (inc<povline) and non-poor > (inc>=povline) households. Also the chances of a household having > income exactly equal to the poverty line are rather low. Also avoid > direct comparison (income==value) since income is stored as decimals, > and you may run into precision problems if your poverty line is not a > round number, but rather generated automatically in your code, etc, > etc, etc. > > Just in case: ADePT Poverty program will do a lot of standard poverty > tabulations: > www.worldbank.org/adept > > Best regards, > Sergiy Radyakin > > On 7/22/08, Ana R. Rios <arorigal@yahoo.com> wrote: >> Dear Stata users, >> >> Could someone suggest a code that will perform the following? >> - I have defined a poverty level based on income per capita (incpc). I >> would like to perform calculations on x number of households above/below >> poverty. >> >> Here is an example: lets assume that the poverty level is an income per >> capita equal to 228.22. I would like to calculate the mean income per >> capita for a total sample of 11 households: 5 households above poverty, 5 >> households below povery and the household at the poverty level. That is, >> the mean income per capita for observations 8 to 18. >> >> obs househol incpc >> 1 18109 15.87111 >> 2 19705 52.32142 >> 3 37503 75 >> 4 25309 80 >> 5 33520 91.14099 >> 6 22905 100 >> 7 4113 150 >> 8 37520 167.7384 >> 9 33102 190 >> 10 28614 192.205 >> 11 28504 227.3124 >> 12 37616 227.3575 >> 13 37620 228.22 >> 14 33518 235.8528 >> 15 33315 236.0431 >> 16 4205 250 >> 17 5210 250 >> 18 23814 252.6725 >> 19 28506 256.8579 >> 20 30912 265 >> >> >> Thank you for your time. >> >> Regards, >> Ana Rios >> >> >> >> >> * >> * 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/ >> > * > * 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/ > * * 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/

**References**:**st: Code***From:*"Ana R. Rios" <arorigal@yahoo.com>

**Re: st: Code***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

- Prev by Date:
**Re: st: Suppress a legend in overlaid twoway graphs** - Next by Date:
**Re: st: importing spss data** - Previous by thread:
**Re: st: Code** - Next by thread:
**Re: st: Code** - Index(es):

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