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
Related Posts with Change variables within a group based on other observations in this group
LoopHello I have a panel data of ten 9 countries, I want to run this code for the pair of 4 countries …
Pooled Regression with time variableHi All, I have annual data, and I want to run a pooled OLS regression and include a time variable a…
qlqc30 command questionHi, I'm trying to analyze quality of life data using the qlqc30 command (https://journals.sagepub.co…
Heckman selection model instrument validityHello I have a question about instrument validity in Heckman's selection model. For this purpose, I …
Creating a new variable based on all the following values of an existing variableHello -- I was unsure how to word the title, but hopefully it offers some clue as to what I am tryin…
Subscribe to:
Post Comments (Atom)
0 Response to Change variables within a group based on other observations in this group
Post a Comment