Hello,
my dataset is structered the following:
group_id regression_dummy
1 0
2 1
2 2
2 2
3 2
3 1
4 1
4 1
4 1
4 1
4 1
5 1
6 1
6 2
7 0
8 1
8 1
8 1
9 1
9 1
9 1
My problem is the follwing: The variable regression_dummy is either be a 0, 1 or 2.
What I want now is that if within a group (indicated by the variable group_id) there are one or more observations whose regression_dummy is a 2 every 1 in this group should get a 0. This means in the end it should look like this:
group_id regression_dummy
1 0
2 0
2 2
2 2
3 2
3 0
4 1
4 1
4 1
4 1
4 1
5 1
6 0
6 2
7 0
8 1
8 1
8 1
9 1
9 1
9 1
I hope you can help me solving this problem.
Greetings
Marcel
0 Response to Change variables within a group based on other observations in this group
Post a Comment