Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Sums and means for each decile |

Date |
Thu, 11 Oct 2012 16:39:15 +0100 |

Here's one way to do it. I find this more direct -- and more flexible -- than what the manual seems to imply you should do, but I could easily be missing something. webuse nlswork, clear _pctile age, p(10(10)90) ret li gen decile = 10 qui forval i = 9(-1)1 { replace decile = `i' if age < r(r`i') } tabstat age, by(decile) s(n sum mean) On Thu, Oct 11, 2012 at 4:24 PM, Charles Vellutini <charles.vellutini@ecopa.com> wrote: > Thanks Nick and sorry for the lack of clarity. > > -decile- does not exist, I meant -centile-, my mistake. > > What I want are sums and means of the same variable that was used to determine the percentiles -- but now that you mention it, it would nice to have that on other variables too! > > Thanks, > Charles > > -----Message d'origine----- > De : owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] De la part de Nick Cox > Envoyé : jeudi 11 octobre 2012 17:15 > À : statalist@hsphsun2.harvard.edu > Objet : Re: st: Sums and means for each decile > > What's -decile-? > > You're right about -pctile-. But what do you want? > > sums, means of some variable y in classes determined by selected percentiles of another variable x? > > sums, means of a variable x in classes determined by selected percentiles of the same variable x? > > On Thu, Oct 11, 2012 at 4:09 PM, Charles Vellutini <charles.vellutini@ecopa.com> wrote: > >> I have looked at -decile- and -pctile- but neither provides the sums and means of each decile/percentile (only the cutoffs), if I am not mistaken. >> >> One could of course recover the cutoffs from -decile- and program this by hand. There is also the excellent -glcurve- available from SSC but this produces graphs; it creates variables that, yes, could also be used to compute the sums I suppose. >> >> But I thought that someone surely programmed this already? > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Sums and means for each decile***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: Sums and means for each decile***From:*Charles Vellutini <charles.vellutini@ecopa.com>

**Re: st: Sums and means for each decile***From:*Nick Cox <njcoxstata@gmail.com>

**RE: st: Sums and means for each decile***From:*Charles Vellutini <charles.vellutini@ecopa.com>

- Prev by Date:
**RE: st: Sums and means for each decile** - Next by Date:
**Re: st: Sums and means for each decile** - Previous by thread:
**RE: st: Sums and means for each decile** - Next by thread:
**Re: st: Sums and means for each decile** - Index(es):