Hello All,
Please could you help me?
Could you help me identify what's not working in the code below, please? What I'm trying to do is find the second value after the minimum in a set of 7 variables, while also considering conditions regarding other variables. When executing this code, it often happens that the two variables created have the same values, and the condition that the second variable should be greater than the first is not met.
Here is the code:
gen Var1 =.y
forvalues i=1/7 {
replace Var1 = ACHB`i'C if ACHB`i'C < Var1 & ~missing(ACHB`i'C) & RCI30_`i'== 1
}
gen Var2 =.y
forvalues i=1/7 {
replace Var2 = ACHB`i'C if (ACHB`i'C > Var1 & ACHB`i'C < Var2) & ~missing(ACHB`i'C) & (RCI30_`i'== 1)
}
Thank you for your assistance.
Please could you help me?
Could you help me identify what's not working in the code below, please? What I'm trying to do is find the second value after the minimum in a set of 7 variables, while also considering conditions regarding other variables. When executing this code, it often happens that the two variables created have the same values, and the condition that the second variable should be greater than the first is not met.
Here is the code:
gen Var1 =.y
forvalues i=1/7 {
replace Var1 = ACHB`i'C if ACHB`i'C < Var1 & ~missing(ACHB`i'C) & RCI30_`i'== 1
}
gen Var2 =.y
forvalues i=1/7 {
replace Var2 = ACHB`i'C if (ACHB`i'C > Var1 & ACHB`i'C < Var2) & ~missing(ACHB`i'C) & (RCI30_`i'== 1)
}
Thank you for your assistance.
Comment