I have a dataset with observations that have been matched, and I have a sample weight for the controls that comes from before I did this matching. So, all the treated observations have a NA in my weight variable. I need to replace those NA with the weight from the control observation that has been matched. My data looks something like this:
weight | Treated | _id | _n1 |
NA | 0 | 1 | . |
NA | 0 | 2 | . |
NA | 0 | 3 | . |
NA | 0 | 4 | . |
2.654 | 1 | 5 | 1 |
10.23 | 1 | 6 | 2 |
5.378 | 1 | 7 | 3 |
8.539 | 1 | 8 | 4 |
weight | Treated | _id | _n1 |
2.654 | 0 | 1 | . |
10.23 | 0 | 2 | . |
5.378 | 0 | 3 | . |
8.539 | 0 | 4 | . |
2.654 | 1 | 5 | 1 |
10.23 | 1 | 6 | 2 |
5.378 | 1 | 7 | 3 |
8.539 | 1 | 8 | 4 |
I'm having trouble with programming this replacement. I hope you can help me and thank you very much in advance
0 Response to Replace value from different row condtions
Post a Comment