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 |
Guo Xu <digitalepourpre@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: calculating mean without own observation |

Date |
Mon, 23 May 2011 16:32:20 +0200 |

Dear Stata list, How do I calculate a mean (or any other summary statistic) excluding the *current* observation? For example, I have following data: i value category 1 5 1 2 5 1 3 10 1 4 2 2 5 2 2 I would like to calculate the mean for each category (egen value_mean = mean(value), by(category)), but exclude the i-th observation: For i=1, for example, the mean value by category 1 would be (5+10)/2. For i=3, it would be (5+5)/2. For i=4, it would be 2/1. I guess there must be some simple *if* condition for this manipulation, but I failed to find it - would be most grateful for help. Thanks, Guo * * 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/

**Follow-Ups**:**st: RE: calculating mean without own observation***From:*Nick Cox <n.j.cox@durham.ac.uk>

**Re: st: calculating mean without own observation***From:*Phil Clayton <philclayton@internode.on.net>

- Prev by Date:
**st: repeated measures** - Next by Date:
**Re: st: repeated measures** - Previous by thread:
**st: repeated measures** - Next by thread:
**Re: st: calculating mean without own observation** - Index(es):