Hello Everyone:
I have a dataset in this format.
a b a1 a2 a3 a4
1 0 2 4 6 8
2 1 3 1 5 7
3 1 2 4 6 7
4 0 2 3 1 5
5 0 1 4 3 2
6 1 2 5 7 9
7 0 8 5 3 2
8 1 3 6 7 2
9 0 1 5 3 2
10 1 7 9 2 1
;
Please note that for any observation (row), a is not equal to a1, a2, a3, and a4. Basically what I want do is to assign 0/1 to the variables a1-a4 based on variable 'a''s association with b. So for example, when a = 3, b = 1. Now, I want a value of 1 to be assigned to variables a1-a4 whose value anywhere in the dataset is equal to 3. When a1 = 7 (10th observation), then the value of 7 needs to be replaced by 0 since when a = 7 b = 0, and so forth. Any suggestion will be greatly appreciated. Thank you.