Hi all, I am trying to calculate a peer-bank Herfindahl–Hirschman Index (HHI) using bank loans each year. The HHI observation for each bank in my panel dataset will be the market concentration of all peer-banks, excluding the bank itself. Therefore, each bank-year observation will have a unique vale. I'm sure there is a macro that could do this, but I have not been able to create one that works. Here is a sample of my data showing the banks and loan amounts each year. Is there any macro that I could use to calculate this peer_hhi? data loans;
input year bank $ loan_amount;
datalines;
2010 BankA 100000
2010 BankB 150000
2010 BankC 200000
2010 BankD 120000
2010 BankE 1000000
2011 BankA 200000
2011 BankB 50000
2011 BankC 400000
2011 BankD 100000
2011 BankE 1500000
;
run; As an example, the variable I am looking for peer_hhi for BankA in 2010 would be calculated with the data for BankB, C, D, E in 2010. See below peer_hhi for BankA in 2010: with the 1,470,000 calculated as the sum of all loans for BankB, C, D, E in 2010. The final dataset I am trying to create would look like this: year bank loan_amount peer_hhi 2010 BankA 100,000 4,984 2010 BankB 150,000 5,279 2010 BankC 200,000 5,578 2010 BankD 120,000 5,101 2010 BankE 1,000,000 2,675 2011 BankA 200,000 5,764 2011 BankB 50,000 5,083 2011 BankC 400,000 6,728 2011 BankD 100,000 5,306 2011 BankE 1,500,000 3,778 Thank you in advance for all your help. Please let me know if more information is needed.
... View more