Dear all,

I have a panel data (long data), shown below.
Firm name Year Firm value Dummy
A 1
B 1
C 1
A 2
B 2
C 2
A 3
B 3
C 3
I want to construct a dummy. Rank the firm based on their firm value at Year2.
The dummy takes 1, if the bank ranked at top 1 at Year2.
The dummy takes 0, if it is the lowest one.
Could anyone help me with this issue?

Thank you!!!