Hello,
I am stuck trying to rank a variable conditionally.....I understand rank is an egen function, whilst cond is not
IF var alarm does not equal "0" (string) then var rank_AvgPrbAlarm is ranked as normal
IF var alarm does equal "0" the var rank_AvgPrbAlarm is returned as zero
Here is the code at the moment...
bysort raceid: egen rank_AvgPrbAlarm = rank(cond(alarm != "0" ,(-AvgPrbAlarm),track,0))
which is returning the error message 'track not found'
Any help appreciated please
0 Response to Rank with a Condition
Post a Comment