Hi,

I am using panel data with the following structure: a single task (Task_id, also the panel id) attracts multiple entries (Entry_id) over time. Each entry receives a performance score (between 0 and 1).

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int task_id long entry_id float entry_performance
1  1  .3610236
1  2  .5415809
1  3   .374851
1  4  .5415809
1  5 .47416735
1  6 .47416735
1  7  .5049182
1  8  .3841909
1  9     .4958
1 10  .5889756
1 11 .59394366
1 12  .5415809
1 13  .4594968
2  1  .3826254
2  2  .7526277
2  3  .7923552
2  4  .8073489
2  5  .3816767
2  6  .4103796
end
For each entry in each task, I am trying to count how many prior entries have higher values entry_performance. So, the expected outcome is as follow (output_var):

Code:
* Example generated by    -dataex-. To install: ssc install dataex
clear
input int task_id long    entry_id float(entry_performance output_var)
1  1  .3610236 0
1  2  .5415809 0
1  3   .374851 2
1  4  .5415809 0
1  5 .47416735 2
1  6 .47416735 2
1  7  .5049182 2
1  8  .3841909 5
1  9     .4958 3
1 10  .5889756 0
1 11 .59394366 0
1 12  .5415809 2
1 13  .4594968 9
2  1  .3826254 0
2  2  .7526277 0
2  3  .7923552 0
2  4  .8073489 0
2  5  .3816767 4
2  6  .4103796 3
end

I have tried running this with loops but as the number of entries grow in a task, the time taken increases exponentially. I have tried using rangestat and rangerun but could not make things work.

Any help is highly appreciated. Thanks in advance.