Hello,
I am trying to create the following dummy variable:

dummy variable that takes the value of 1 (and 0 otherwise) if an audit firm is the number one auditor in terms of aggregated audit fees in a specific year (a minimum of 2 observations in required.

* Example generated by -dataex-. For more info, type help dataex
clear
input str8 var1 str10 var2 str11 var3 str4 var4 str9 var5
"city" "Audit firm" "client code" "year" "audit fee"
"Antwerp" "EY" "A" "2020" "1000"
"Antwerp" "EY" "B" "2020" "200"
"Brussels" "EY" "C" "2019" "500"
"Paris" "Deloitte" "D" "2013" "2000"
"Paris" "Deloitte" "E" "2013" "1000"
"Vienna" "Deloitte" "F" "2014" "100"
"Vienna" "Deloitte" "G" "2014" "75"
end
[/CODE]
------------------ copy up to and including the previous line ------------------

Listed 8 out of 8 observations


Expected Outcome:
city Audit firm client code year audit fee Industry leader
Antwerp EY A 2020 1000 1
Antwerp EY B 2020 200 0
Brussels EY C 2019 500 0
Paris Deloitte D 2013 2000 1
Paris Deloitte E 2013 1000 0
Vienna Deloitte F 2014 100 1
Vienna Deloitte G 2014 75 0


Thank you in advance!