I am new to stata, and I am trying to create a new variable (z) which takes the largest value from two pre-existing variables, i.e. if x = 6 and y = 5 z = 6.
The current code I am using is not working properly, as if the score in variable y is lower than x, z is being populated with y instead of x.
Please see the code below:
gen w1ei1 = w1eimotherrecode if w1eimotherrecode >= w1eifatherrecode ! =.a
replace w1ei1 = w1eifatherrecode if w1eifatherrecode >= w1eimotherrecode ! =.a
If anyone can help with it would be greatly appreciated!
The current code I am using is not working properly, as if the score in variable y is lower than x, z is being populated with y instead of x.
Please see the code below:
gen w1ei1 = w1eimotherrecode if w1eimotherrecode >= w1eifatherrecode ! =.a
replace w1ei1 = w1eifatherrecode if w1eifatherrecode >= w1eimotherrecode ! =.a
If anyone can help with it would be greatly appreciated!
Comment