local x=500
tempvar dist
gen `dist'=abs(`x'-inc)
sum `dist'
sum inc if `dist'=r(min)
Regards, S.R.
On 7/23/08, Ana R. Rios <[email protected]> wrote:
> Stata users,
>
> I would like to obtain the incpc that is closest to x value. For example, if x=500 the incpc will be 360.
>
> househol incpc obs
> 37620 228.22 1
> 33013 323.75 2
> 19319 360 3
> 6211 750 4
> 31814 813.75 5
> 28820 982.6588 6
> 17905 993.0207 7
> 10022 1122.5 8
> 5116 1145.833 9
> 7521 1151.435 10
> 6105 1193.125 11
> 32410 1274.714 12
> 5218 1278 13
> 9920 1278 14
> 36517 1328.5 15
> 9614 1375 16
> 6203 1395 17
> 6213 1448.333 18
> 7206 1460 19
> 32414 1470 20
>
> I would appreciate any help.
>
> Thanks for your time.
>
> 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/