Please consider the following sample data
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id round location) 1 1 1 1 2 1 1 3 1 2 1 2 2 2 2 2 3 4 3 1 3 3 2 4 3 3 3 end
I tried
Code:
sort id round by id: replace location=location[_n-1]|location[_n-2] if location!=location[_n-1]|location!=location[_n-2]
Would appreciate if someone could suggest how to go about this problem.
Thanks
0 Response to How to replace value of a variable in one round with its value in a previous round ?
Post a Comment