generate a new variable X=A+B, if A is missing, then replace with C; if both A and C are missing, replace with D. 有一个顺序在里面,就是如果对于每一个观察变量,如果没有A的值,就用C代替;如果C也没有,就用D代替。这样的语句应该怎么写啊?求助各位知道的朋友。谢谢大家了!
gen x=a+b if a<. & b<. //both a and b are not missing
replace x=c+b if a==. & c<. //a is missing, c is not missing
replace x=d+b if a==. & c==. //both a and c are missing