I want to rank each id based on two categories: cat1 and cat2. For example, "death" < "pd" < "pr", and 1 < 2 < 3 < 4, and thus, the rank for each patient should be as follows:
id  cat1    cat2    rank
1   death   1        1
2   death   2        2
3   death   3        3
4   death   4        4
5   pd      1        5
6   pd      2        6
7   pd      3        7
8   pd      4        8
9   pr      1        9
10  pr      2        10
11  pr      3        11
12  pr      4        12