Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: median of consecutive groups - avoiding loops


From   Nick Cox <[email protected]>
To   [email protected]
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
<[email protected]> 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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index