Hi all, I want to perform a hierarchical if condition within a group. My data structure looks like the following: Facilityid Lender LenderRole LeadArrangerCredit AgentCredit 1 Deutsche Bank Arranger Yes No 1 Goldman Admin Agent No No 1 JP Morgan Participant No No 1 Citi Administrative Agent No No 2 Morgan Stanley Manadated Lead arranger No No 2 Wells Fargo Bookrunner No No 2 UBS Bookrunner No No 2 Credit Suisse Bookrunner Yes No 3 Deutsche Bank Administrative Agent No Yes 4 JP Morgan Bookrunner No No 4 Goldman Bookrunner No No 4 Citi Bookrunner No No 4 UBS Bookrunner No Yes I want to code a dummy variable (lead_arranger) per Facilityid group. Thereby, the following restrictions apply: - If any Lender has the role of "Administrative Agent" it is deemed as the lead arranger (i.e. lead_arranger = 1) - If there is no "Administrative Agent", the Lender which is the LeadArrangerCredit is the lead arranger - If there is no "Administrative Agent" and no LeadArrangerCredit, the Lender with the AgentCredit is the lead arranger - For loans with only one lender (i.e. only one observation per facilityid group), this lender is automatically the lead arranger - If none of the above is true, there is no lead arranger Thank you so much!
... View more