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
Recentered Influence Functions (RIF) in Stata: RIF-Regression and RIF-DecompositionDear all, Thanks to Prof Baum, a new update to the "oaxaca_rif" command is now available. This new u…
Estimate equations simultaneously with Maximum Likelihood methodsHi all, I am trying to replicate a methodology used by an academic paper where they estimate 3 equa…
Using stset for recurring event analysisHi all, Apologies if this is very simple. I'm trying to run a recurring-event survival analysis us…
oprobit/ ologit for grouped data?Dear All, I am wondering if there exists an equivalent of blogit/ bprobit for ordered logistic regr…
Problem with variable and its format.Hello, I have a mock data set and one variable is "country" with the corresponding two letters "AT" …
Subscribe to:
Post Comments (Atom)
0 Response to Change variables within a group based on other observations in this group
Post a Comment