Hello,
I am reaching out to check if I have used sample weights correctly. I am calculating the percentage of households with food-insecure children in each state and year and then collapsing the percentages to generate a state-level variable. Do I also need to use sample weights in the initial steps (codes are below) when calculating my numerator and denominator for percentages? I tried to do it, but Stata wouldn't allow me to use sample weights with counts (unless I used it incorrectly).
bysort year statefip: egen insec_num = count (hh_child_insec) if hh_child_insec ==1
bysort year statefip: egen insec_denom = count (hh_child_insec) if hh_child_insec !=.
bysort year statefip: gen insec_per = (insec_num / insec_denom) * 100 if insec_denom > 0
collapse (mean) state_food_insec = insec_per [aweight=fshwtscale], by (year statefip)
Thanks,
Arun
I am reaching out to check if I have used sample weights correctly. I am calculating the percentage of households with food-insecure children in each state and year and then collapsing the percentages to generate a state-level variable. Do I also need to use sample weights in the initial steps (codes are below) when calculating my numerator and denominator for percentages? I tried to do it, but Stata wouldn't allow me to use sample weights with counts (unless I used it incorrectly).
bysort year statefip: egen insec_num = count (hh_child_insec) if hh_child_insec ==1
bysort year statefip: egen insec_denom = count (hh_child_insec) if hh_child_insec !=.
bysort year statefip: gen insec_per = (insec_num / insec_denom) * 100 if insec_denom > 0
collapse (mean) state_food_insec = insec_per [aweight=fshwtscale], by (year statefip)
Thanks,
Arun
Comment