How can I rank observations within groups in Stata?

前端 未结 6 1456
闹比i
闹比i 2020-12-21 01:30

I have some data in Stata which look like the first two columns of:

group_id   var_to_rank  desired_rank
____________________________________

1           10         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-21 01:56

    Way too much work. Easy and elegant. Try this one.

    gen desired_rank=int(var_to_rank/10)

提交回复
热议问题