Dear Stata Forum,
My query relates to combining the if and the and (&) operator in creating a new variable. So far, I have gen newvar =99 and replace newvar = 6 if original_a != 0 & original_a == changed1_a == changed2_a
In essence, this variable should equal 6 if original_a is not equal to 0 and the original, changed1, and changed2 variables are all the same. For example, newvar should equal 6 if the original, changed1, and changed2 all equal to 75.
I have other replaces in place, which all work fine, for example: replace newvar =1 if original_a < changed1_a < changed2_a
I feel the issue lies in the combination of the two operators. Following https://www.statalist.org/forums/for...=1683535816935 and Mr. Schechter's comment about the order, I have also tried to implement if original_a == == changed1_a == changed2_a & original_a != 0. Likewise, parentheses also did not help.
I would be most grateful for any advice!
Kind regards,
Mary Burckhette
My query relates to combining the if and the and (&) operator in creating a new variable. So far, I have gen newvar =99 and replace newvar = 6 if original_a != 0 & original_a == changed1_a == changed2_a
In essence, this variable should equal 6 if original_a is not equal to 0 and the original, changed1, and changed2 variables are all the same. For example, newvar should equal 6 if the original, changed1, and changed2 all equal to 75.
I have other replaces in place, which all work fine, for example: replace newvar =1 if original_a < changed1_a < changed2_a
I feel the issue lies in the combination of the two operators. Following https://www.statalist.org/forums/for...=1683535816935 and Mr. Schechter's comment about the order, I have also tried to implement if original_a == == changed1_a == changed2_a & original_a != 0. Likewise, parentheses also did not help.
I would be most grateful for any advice!
Kind regards,
Mary Burckhette
Comment