Dear All, I have the data
and for each id, I'd like to calculate the average value of those values of other `id's larger than the value of `id'. For instance, for id=1, the values of all other `id's are larger than 100 (id=1). As such, I want to calculate y=(130+230+120+160)/4. For id=2, the values of id=3 (230) and id=5 (160) are larger than 130 (id=2). As such, I want to calculate y=(230+160)/2. And so on. Anys suggestions?
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id profit) 1 100 2 130 3 230 4 120 5 160 end
Comment