Dear all,

I have a simple problem for which I have not been able to find a solution. Imagine a very simple dataset regarding bank loans with three columns/variables. Variable 1 shows the distinct id variable for each loan in my sample. Variable 2 shows the lenders that were involved in making the loan (there can be multiple lenders per loan). Variable 3 shows the role of each lender for a specific loan (assume there can only be four roles: a,b,c,d).

How can I generate a new variable that shows me the number of banks with role b or c per loan?

Thanks in advance.

Regards, Ali