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
Regressions with multiple splitsHi! I have a question regarding regression output I would like to get as efficiently as possible. I…
Loops I have two questions regarding two problems that I have been facing so far. First after runni…
P-Values for Heteroskedasticity-Robust InferenceHi there, What distribution are the p-values based off of when an OLS regression of y on 1,x1,...,x…
Convert column into rowHi , I want to transport the follwoing data sample ( column into row ) ----------------------- copy…
Ensuring correct model specification (diff-in-diff)Hello! I am studying the impact of non-monetary rewards incentive introduced by online platform on …
Subscribe to:
Post Comments (Atom)
0 Response to Change variables within a group based on other observations in this group
Post a Comment