答案 0 :(得分:0)
假设id_mother
中的folio
相同(如果没有丢失),那么如下所示呢?
egen famid = group(folio)
sort famid
by famid: egen mmm = mean(id_mother)
by famid: egen kkk = count(id_mother)
gen mmnino = kkk if famid*100+ls==famid*100+mmm
drop famid kkk mmm
list
如果folio
是数字,则不需要第一行。应该尝试用实际数据来调试。而不是第4行(对于egen kkk
),您也可以执行以下操作:
by famid: egen sss = sum(id_mother)
gen kkk = sss/mmm