Hi,
I'm counting how many missing values(.) a variable has, and my previous code only counted 0 and 1 variables, making the 0 and missing values combined.
I'm now trying to separate the missing values from the 0 but I've failed many many times, the number of 1 is not matched with the previous one, can someone please guide me how to count 1, 0, missing value(.) separately?
gen O1 = 0
replace O1 = 1 if under == 0 & inlist(c314, 1, 2) & (inlist(c300, 1, 2, 3, 4) | c304 == 1 | inlist(c3, 3, 4, 5) | inlist(c340, 3, 4, 5, 6) | inlist(c350, 3, 4, 5, 6) | inlist(c321, 1, 2) | inlist(c3, 1, 2) | c323 == 2)
gen O2 = 0
replace O2 = 1 if (inlist(c340, 2, 3) | inlist(c350, 2, 3)) & (inlist(c360, 2, 3) | inlist(c370, 1, 2) | inlist(c371, 1, 2) | inlist(c372, 1, 2) | inlist(c373, 1, 2) | inlist(c374, 1, 2) | inlist(c375, 1, 2))
gen O3 = 0
replace O3 = 1 if c340 == 1 & c350 == 1 & inlist(c360, 2, 3) & (inlist(c370, 1, 2) + inlist(c371, 1, 2) + inlist(c372, 1, 2) + inlist(c373, 1, 2) + inlist(c374, 1, 2) + inlist(c375, 1, 2)) >= 3
gen OS = 0
replace OS = 1 if (O1 == 1 | O2 == 1 | O3 == 1) & A14 == 0 & B14 == 0 & D14 == 0
I'm counting how many missing values(.) a variable has, and my previous code only counted 0 and 1 variables, making the 0 and missing values combined.
I'm now trying to separate the missing values from the 0 but I've failed many many times, the number of 1 is not matched with the previous one, can someone please guide me how to count 1, 0, missing value(.) separately?
gen O1 = 0
replace O1 = 1 if under == 0 & inlist(c314, 1, 2) & (inlist(c300, 1, 2, 3, 4) | c304 == 1 | inlist(c3, 3, 4, 5) | inlist(c340, 3, 4, 5, 6) | inlist(c350, 3, 4, 5, 6) | inlist(c321, 1, 2) | inlist(c3, 1, 2) | c323 == 2)
gen O2 = 0
replace O2 = 1 if (inlist(c340, 2, 3) | inlist(c350, 2, 3)) & (inlist(c360, 2, 3) | inlist(c370, 1, 2) | inlist(c371, 1, 2) | inlist(c372, 1, 2) | inlist(c373, 1, 2) | inlist(c374, 1, 2) | inlist(c375, 1, 2))
gen O3 = 0
replace O3 = 1 if c340 == 1 & c350 == 1 & inlist(c360, 2, 3) & (inlist(c370, 1, 2) + inlist(c371, 1, 2) + inlist(c372, 1, 2) + inlist(c373, 1, 2) + inlist(c374, 1, 2) + inlist(c375, 1, 2)) >= 3
gen OS = 0
replace OS = 1 if (O1 == 1 | O2 == 1 | O3 == 1) & A14 == 0 & B14 == 0 & D14 == 0
Comment