I'm having a hard time generating dummy variables using a for loop. I have a variable with some values, now I want to create a dummy variable for each value such that if it takes the specific value it will return 1 otherwise it will return 0. I can't make it work since I always end up creating one new variable with all values being equal to 1. I have posted two pictures, the first one is the variable and the second one is how I want it to look like.
Array

I want it to look like this:

Array