I have a string var that lists a number of services separated by comma. I'd like each service to become its own var with 1/0 observations. Here is an example using colors below.
Note that there are 45 unique values within the string var I'm using. The list is always in alphabetical order in the original format. There are also spaces and/or dashes in some of the service names.
I've searched online a bit, but I don't think I'm wording the question well enough to find answers out there! Thank you!
Current data format:
Ideal format:
Note that there are 45 unique values within the string var I'm using. The list is always in alphabetical order in the original format. There are also spaces and/or dashes in some of the service names.
I've searched online a bit, but I don't think I'm wording the question well enough to find answers out there! Thank you!
Current data format:
ID | Colors |
1 | Bluish Green, Green, Orange, Purple |
2 | Green, Purple, Red, Yellow |
3 | Blue, Green, Orange, Purple, Red, Yellow |
4 | Orange, Purple, Red, Yellow |
Ideal format:
ID | BluishGreen | Blue | Green | Orange | Purple | Red | Yellow |
1 | 1 | 0 | 1 | 1 | 1 | 0 | 0 |
2 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
3 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
4 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
Comment