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]

st: median of consecutive groups - avoiding loops


From   "Sarah Kristina Reuter" <[email protected]>
To   [email protected]
Subject   st: median of consecutive groups - avoiding loops
Date   Wed, 11 May 2011 19:47:50 +0200

Hello everyone,
I do not know if the following is possible, I hope anyone has an idea how to address it.
I would like to create a variable that gives me the median of two consecutive groups for every group. Here is an example:

id         group   value   median
1          1          5          ?
2          1          7          ?
3          1          8          ?
4          2          3          ??
5          2          5          ??
6          3          5          ???
7          3          7          ???
8          3          4          ???
9          3          2          ???
10        3          8          ???


The first ? should be the median of id 1-5, the ?? the median of id 4-10 and the ??? the one of id 6-10.

Does anyone know a command that would do this without needing to write a loop? Really looking forward to any recommendations!

Best regards
Sarah Reuter
 


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