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 on April 23, and its replacement, statalist.org is already up and running.


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

st: median of consecutive groups - avoiding loops


From   "Sarah Kristina Reuter" <sarah.kristina.reuter@uni-jena.de>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index