Good morning,

I have 3 variables that I need to rank.
There are some cells in those variables that contain no data.
These I would like to have ranked as -1.
Could anybody help me out please?


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(raceid prcaverage prclastrun prc2ndlastrun) float(rank_prcaverage rank_prclastrun rank_prc2ndlastrun)
1 96 93 98  1  7  1
1 91 90 89  9 10  6
1 95 97 95  4  3  3
1 93 94 94  6  5  4
1 94 94 91  5  5  5
1 96 96  .  1  4  .
1 96  .  0  1  . 10
1  . 93 96  .  7  2
1 92 91 88  7  9  7
1 92 99 86  7  1  9
1 90 98 87 10  2  8
end
Here is the code that I am using at the moment...

sort raceid
foreach v in prcaverage prclastrun prc2ndlastrun {
by raceid: egen rank_`v' = rank(-`v'),track
}