I would like to create a variable that is the maximum value, but not have it take over the entire variable for all waves.
Here is what I'm dealing with specifically: I am interested in what happens to my DV if a child's mother gets divorced. Divorced=1, married=0. So once a mother divorces I want to keep that set to 1 for the waves following, even if she remarries.
Let's say I have a mother who is married from 1993-1994 (divorced=0). In 1995, she is divorced (divorced=1). In 1996 and 1997, she is married again (divorced=0).
93: 0
94: 0
95: 1
96: 0
97: 0
I would like the 0 in 96, 97 and from there on out to stay a 1 since she has been divorced and her child experienced that divorce, but do not want to overwrite the 0's from 92-94.
Right now I am using a max(var) syntax: egen max_div=max(divorced), by (child_id)
But that gives me 1's for all waves (and while there is certainly value of knowing the marriage was on the rocks and seeing the impact that has on the child, that is not my focus right now).
How can I keep the maximum value of a variable after it becomes the maximum value (in this case 1), but not overwrite the prior maximum value (in this case 0)?
Thanks!
Here is what I'm dealing with specifically: I am interested in what happens to my DV if a child's mother gets divorced. Divorced=1, married=0. So once a mother divorces I want to keep that set to 1 for the waves following, even if she remarries.
Let's say I have a mother who is married from 1993-1994 (divorced=0). In 1995, she is divorced (divorced=1). In 1996 and 1997, she is married again (divorced=0).
93: 0
94: 0
95: 1
96: 0
97: 0
I would like the 0 in 96, 97 and from there on out to stay a 1 since she has been divorced and her child experienced that divorce, but do not want to overwrite the 0's from 92-94.
Right now I am using a max(var) syntax: egen max_div=max(divorced), by (child_id)
But that gives me 1's for all waves (and while there is certainly value of knowing the marriage was on the rocks and seeing the impact that has on the child, that is not my focus right now).
How can I keep the maximum value of a variable after it becomes the maximum value (in this case 1), but not overwrite the prior maximum value (in this case 0)?
Thanks!
Comment