推 jadebear:大感謝!!! 12/27 22:05
第一題跟第二題
子女教育年平均數 教育年標準差 子女數 (COUNT是計算非性別的缺失值 ) 女生數量
collapse (mean) avgeduc = seduc (sd) seduc (count) nosib= sgender (sum)
nosis= sgender , by(idno2)
第三題
將三名子女以上家庭用男女誰比較多分三組
gen nobro=nosib-nosis
gen familytype=1 if nosis==nobro
replace familytype = 2 if nobro>nosis
replace familytype = 3 if nobro<nosis
將直式變橫式
reshape wide seduc sgender, i(idno) j(si)
然後計算家庭子女人數
egen nosib= rnonmiss(sgender1 sgender2 sgender3 sgender4 sgender5 sgender6)
耶?沒有ROWNONMISS 那就跳過吧
30頁的練習
用直式的作法
collapse (sd) seduc = seduc (max) maxduc= seduc, by(idno2)
sort idno2
save sib, replace
兩個檔案都要SORT
merge idno2 using sib3.dta
gen gap = maxduc-seduc
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.157.129