This is the given dataset
Ins_id Prod1 Prod2 Prod3 Prod4
1234 1 0 1 0
5678 0 0 1 0
91011 0 1 0 1
12131 1 1 0 1
I want to create a new column that displays all the column names when the corresponding value is 1. So for example, for ins_id=1234, the string would be 'Prod1, Prod3'. There are at least 40 variables.
Expected Output:
Ins_id Prod1 Prod2 Prod3 Prod4 Prod_Yes
1234 1 0 1 0 Prod1, Prod3
5678 0 0 1 0 Prod3
91011 0 1 0 1 Prod2, Prod4
12131 1 1 0 1 Prod1, Prod2, Prod4
Can someone please help? Appreciate it!