Company_ID | Bank_type |
1 | 1 |
1 | 3 |
2 | 5 |
3 | 9 |
3 | 1 |
3 | 2 |
4 | 3 |
4 | 3 |
5 | 1 |
6 | 1 |
6 | 1 |
7 | 4 |
7 | 7 |
7 | 1 |
7 | 2 |
7 | 3 |
I have a data set looking like this one. There are different firms, identified by Company_ID. These different firms are customers of different type of banks, some of them have just one bank, some of them more. Now I would like to have a new variable (bank_code) that assigns to each firm exactly one number, that tells me the combination of bank types. So this new variable should be 13 for firm 1, 5 for firm 2, 129 for firm 3 and so on...unfortunately even after looking through the forum and google for some hours I still have no idea how to perform this in Stata. Can the collapse command help, or is there some way with egen? Any help would be greatly appreciated! Thanks a lot!
Comment