fcollapse with any missing weights returns all missing
mcaceresb opened this issue · 1 comments
mcaceresb commented
Consider
clear
set obs 10
gen x = _n
gen y = 1
replace y = . if mod(_n, 3) == 0
gen g = mod(_n, 5)
Missing weights should be dropped, but instead all the results are missing
. which fcollapse
/home/mauricio/ado/plus/f/fcollapse.ado
*! version 2.24.1 15jan2018
. preserve
. fcollapse x [fw = y], by(g)
. l
+-------+
| g x |
|-------|
1. | 0 . |
2. | 1 . |
3. | 2 . |
4. | 3 . |
5. | 4 . |
+-------+
. restore
. collapse x [fw = y], by(g)
. l
+---------+
| g x |
|---------|
1. | 0 7.5 |
2. | 1 1 |
3. | 2 4.5 |
4. | 3 8 |
5. | 4 4 |
+---------+
sergiocorreia commented
Agreed! I was skipping marksample
on some cases, but it should be fixed now.