Bookmark and Share

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, is already up and running.

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

Re: st: median of consecutive groups - avoiding loops

From   Nick Cox <>
Subject   Re: st: median of consecutive groups - avoiding loops
Date   Wed, 11 May 2011 23:19:15 +0100

This code won't work for various reasons. One is that the groups
produced are disjoint, but they should overlap.

On Wed, May 11, 2011 at 11:06 PM, daniel klein
<> wrote:
> I guess in most situations there is a way to work around.
> Try
> g int new_group = cond(mod(group, 2), group, group-1)
> bys new_group : egen median = median(value)
> However, in general I think there is no way you can use Stata
> efficiently without loops.
*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index