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
Related Posts with Rank with a Condition
Renaming multiple string values of a variableHello all. I have an ICD10 code variable that has about 6000 different values in string format. I al…
January effect regressionHello Guys I have a question related to regression. I have a Data in which in the columns there are…
KMatch: Memory Management in Nearest-Neighbor Matching with TiesHi Everyone! Currently running Stata 16. I'm trying to do nearest neighbor matching with Kmatch usi…
Creating a time series dummy variableDear STATAlist community, I am looking for help in creating a dummy variable for a time series. Thi…
Controlling numbers with esttabHi Stata community, I have several regressions that I would ideally put in one table, but there are…
Subscribe to:
Post Comments (Atom)
0 Response to Rank with a Condition
Post a Comment