I was working on a .ado file which was finsihed successfully. Unofrtunately there is a problem with missings I'm not getting rid of. I simplyfied the final result in this example, but solving it would really help me.
So this is the program, displaying the number of missing values at the end.
Code:
program test_miss version 16 syntax varlist(max=2 numeric) [if] [in] local var1 = word("`varlist'",1) local var2 = word("`varlist'",2) marksample touse qui: count if `touse' local N = `r(N)' qui: tabulate `var1' `var2' if `touse' qui: d local miss = `r(N)' - `N' display "number of missings: N= " `miss' end
Code:
**** ** Test 1 **** input byte cat1 byte cat2 byte cat3 1 2 1 3 1 1 1 1 1 1 2 1 2 2 2 2 3 2 1 3 2 1 3 2 end test_miss cat1 cat2 // 0 Missings --> correct test_miss cat1 cat2 if cat3 == 1 // 4 Missings --> not correct (correct = 0)
Code:
**** ** Test 2 **** * equal where the missing is in the 2-way table, it should count as a missing clear input byte cat1 byte cat2 byte cat3 1 . 1 . 1 1 1 1 1 1 2 1 2 2 2 2 . 2 1 3 2 . 3 2 end test_miss cat1 cat2 // 4 Missings --> correct test_miss cat1 cat2 if cat3 == 1 // 6 Missings --> not correct (correct = 2)
I also tried other ways, but again when not using if, everything works fine, when using if, the missing value calculation is not correct.
So hope you have an idea.
Thanks
-Nick
0 Response to Tricky missing problem
Post a Comment