Dear Stata listers,
For the following dataset, I want to do two things: (1) create a quintile rank for continuous variable Xvar, then put it into 5 buckets by creating a quintile rank based on all Xvar value of firms in the same industry and same year. (2) test if this rank has changed over time for each time. Specifically I would like to create Uprank dummy set to one if Xvar rank moved up in ranking i.e. and Downrank dummy set to one if Xvar rank moved lower in ranking.
If you could offer some kind of sample code for (1), that will be very much aprpecaited. For (2) I suppose, I could use some lag function to create change dummy. Your suggestions are more than welcome !
Note: I did not include all panel observations, above is just an illustration.
Best,
Rochelle
For the following dataset, I want to do two things: (1) create a quintile rank for continuous variable Xvar, then put it into 5 buckets by creating a quintile rank based on all Xvar value of firms in the same industry and same year. (2) test if this rank has changed over time for each time. Specifically I would like to create Uprank dummy set to one if Xvar rank moved up in ranking i.e. and Downrank dummy set to one if Xvar rank moved lower in ranking.
If you could offer some kind of sample code for (1), that will be very much aprpecaited. For (2) I suppose, I could use some lag function to create change dummy. Your suggestions are more than welcome !
FirmID | year | xvar | sic2 |
1001 | 1990 | 0.3 | 41 |
1002 | 1990 | 0.4 | 41 |
1003 | 1990 | 0.3 | 41 |
1004 | 1990 | 0.9 | 41 |
1005 | 1990 | 1.1 | 41 |
1006 | 1990 | 2 | 41 |
1007 | 1990 | 1 | 41 |
1008 | 1990 | 1.2 | 41 |
1009 | 1990 | 0.8 | 41 |
1010 | 1990 | 0.1 | 41 |
1001 | 1991 | 0.34 | 41 |
1002 | 1991 | 0.36 | 41 |
1003 | 1991 | 0.41 | 41 |
1004 | 1991 | 0.18 | 41 |
1005 | 1991 | 0.23 | 41 |
1006 | 1991 | 0.21 | 41 |
1007 | 1991 | 0.22 | 41 |
1008 | 1991 | 1 | 41 |
1009 | 1991 | 1.2 | 41 |
1100 | 1990 | 0.23 | 42 |
1101 | 1990 | 0.21 | 42 |
1102 | 1990 | 0.2 | 42 |
1103 | 1990 | 0.4 | 42 |
1104 | 1990 | 0.26 | 42 |
1105 | 1990 | 0.31 | 42 |
1106 | 1990 | 0.42 | 42 |
Best,
Rochelle
Comment