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

From |
Ramani Gunatilaka <Ramani.Gunatilaka@buseco.monash.edu.au> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: thanks - Nearest value |

Date |
Sat, 29 Nov 2003 03:57:23 +0000 |

Renzo, Thanks so much for that. There are unlikely to be any ties because the value for consumption goes up to 4 decimal places. Cheers, Ramani Renzo Comolli <renzo.comolli@yale.edu> wrote: > Read the help for -egen- it will help > > > How do you plan to handle ties (i.e. a case in which there is more than > one > household which is at the same minimal distance from the average > consumption)? > If you plan to pick one of them at random then > . egen meanconsumption=mean(consumption) > . generate absconsumptiondev=abs(meanconsumption-consumption) > . sort absconsumptiondev > . keep in 1 > -sort- already does the maximization for you among ties > > If you plan to keep all the ties > . egen meanconsumption=mean(consumption) > . generate absconsumptiondev=abs(meanconsumption-consumption) > . egen mindevfromavgcons=min(absconsumptiondev) > . keep if absconsumptiondev==mindevfromavgcons > > Ciao > Renzo > > > > ---------------------------------------------------------------------------- > ---- > *From Ramani Gunatilaka <Ramani.Gunatilaka@buseco.monash.edu.au> > To statalist@hsphsun2.harvard.edu > Subject st: Nearest value > Date Sat, 29 Nov 2003 01:13:43 +0000 > > Hi everybody, > This is probably a very simple question, but I have not been able to > figure > out a solution. > I have a data set with consumption and other variables such as number of > adults, district, sector for each household. > I need to write a programme that requires selecting the particular > household > whose consumption is nearest to the mean consumption of all the > households. > Can someone please tell me, what is the Stata command that will do this > for > me? > Thanks, > Ramani > > > * > * 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/ * * 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/

**References**:**Re: st: Nearest value***From:*"Renzo Comolli" <renzo.comolli@yale.edu>

- Prev by Date:
**Re: st: Nearest value** - Next by Date:
**RE: Re: st: Nearest value [small ERRATA CORRIGE]** - Previous by thread:
**Re: st: Nearest value** - Next by thread:
**RE: Re: st: Nearest value [small ERRATA CORRIGE]** - Index(es):

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