Hello everyone,
I have data that looks like this. (This is not the actual data. I just create this as an example to make it easier to understand.)
. list name x1 x2 x3 x4 x5
+---------------------------------+
| name x1 x2 x3 x4 x5 |
|---------------------------------|
1. | Johnny .8 .1 .6 .1 .2 |
2. | Johnny .7 .3 1 .5 .4 |
3. | Johnny .3 1 .2 .8 .5 |
4. | Johnny .7 .4 .9 1 .9 |
5. | Johnny .5 .8 .6 .3 .2 |
+---------------------------------+
There is a name variable and x1-x5 variables. I want to replace the observations based on this rule:
"Once x consists of the values of 1, all of the values for the next x's will be zero"
Simply put, I want my data to look like this:
. list name x1 x2 x3 x4 x5
+---------------------------------+
| name x1 x2 x3 x4 x5 |
|---------------------------------|
1. | Johnny .8 .1 .6 .1 .2 |
2. | Johnny .7 .3 1 0 0 |
3. | Johnny .3 1 0 0 0 |
4. | Johnny .7 .4 .9 1 0 |
5. | Johnny .5 .8 .6 .3 .2 |
+---------------------------------+
How do I command Stata to do that? I have pretty big data and it will be so time-consuming if I replace them one by one.
Thank you in advance.
I have data that looks like this. (This is not the actual data. I just create this as an example to make it easier to understand.)
. list name x1 x2 x3 x4 x5
+---------------------------------+
| name x1 x2 x3 x4 x5 |
|---------------------------------|
1. | Johnny .8 .1 .6 .1 .2 |
2. | Johnny .7 .3 1 .5 .4 |
3. | Johnny .3 1 .2 .8 .5 |
4. | Johnny .7 .4 .9 1 .9 |
5. | Johnny .5 .8 .6 .3 .2 |
+---------------------------------+
There is a name variable and x1-x5 variables. I want to replace the observations based on this rule:
"Once x consists of the values of 1, all of the values for the next x's will be zero"
Simply put, I want my data to look like this:
. list name x1 x2 x3 x4 x5
+---------------------------------+
| name x1 x2 x3 x4 x5 |
|---------------------------------|
1. | Johnny .8 .1 .6 .1 .2 |
2. | Johnny .7 .3 1 0 0 |
3. | Johnny .3 1 0 0 0 |
4. | Johnny .7 .4 .9 1 0 |
5. | Johnny .5 .8 .6 .3 .2 |
+---------------------------------+
How do I command Stata to do that? I have pretty big data and it will be so time-consuming if I replace them one by one.
Thank you in advance.

Comment