Dear Statalister,
I have a dataset with several variables, among which a discrete variable X that looks as follows.
-------------------
X
obs1 60
obs2 60
obs3 60
obs4 70
obs5 71
obs6 71
obs7 71
obs8 71
obs9 71
obs10 71
--------------------
My final purpose is to treat adjacent observations for which the variable X does not change by more than 10% as the same observation.
In other words, I would like to collapse the dataset by X, but whenever the distance between two or more adjacent observations in X is less than 10%, I would like to collapse by a median of x. Before collapsing I tried to generate a median of X whenever the difference within X is less than 10%, and then collapse by X, but I am not succeding. Is this the right approach? Is there a way of collapsing specifying my requirement?
Thank you in advance,
Laura
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
*
* 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/