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
Cohen’s d from a regressionHello, I have a regression coefficient (using the reg command) that I would like to convert to Cohen…
Converting the hazard coefficients to transition probabilities within multistate frameworkHi everyone, Within the multistate life table framework, I am trying to compute transition probabili…
Help to import from ExcelHi. I am trying to import an excel file into Stata. However, when I use the option firstrow, Stata …
count group var if a condition is metHello, I am using Stata 15.1 to analyse household survey data. I want to simply count the number of…
Dropping panel dataHi, I am still new to stata and I have encountered problems. I have this set of data, I only want …
Subscribe to:
Post Comments (Atom)
0 Response to Change variables within a group based on other observations in this group
Post a Comment