Derivation
variable: meals2days (table[s]: css_seh)
variable: mealsnorm (table[s]: css_seh)
variable: tomnum (table[s]: css_seh)
variable: vegnum (table[s]: css_seh)
variable: fishyn (table[s]: css_seh)
variable: chicken (table[s]: css_seh)
variable: meat (table[s]: css_seh)
variable: beans (table[s]: css_seh)
variable: eggs (table[s]: css_seh)
variable: milk (table[s]: css_seh)
variable: foodenough (table[s]: css_seh)
variable: nofood (table[s]: caps_blhse)
<the diet/food availability variables are summarised into a score which is then turned into a decile variable in relation to all other records with this data within the same year>
egen meals2days_cat=cut(meals2days), at(0,1,4,6,99) /*number of meals served in last 2 days categorised into 0, 1-3, 4-5 and 6+*/
recode meals2days_cat 4=2 6=3
egen mealsnorm_cat=cut(mealsnorm), at(0,1,2,3,99) /*number of meals normally served daily categorised into 0, 1, 2 and 3+*/
egen vegetable=rowtotal(tomnum vegnum)
replace vegetable=. if tomnum==. & vegnum==.
egen veg_cat=cut(vegetable), at(0,2,6,10,15) /*number of days tomatoes and veg served in last 7 days categorised into 0-1, 2-5, 6-9 and 10+*/
recode veg_cat 2=1 6=2 10=3
egen protein=rowtotal(fishyn chicken meat beans eggs milk)
replace protein=. if fishyn==. & chicken==. & meat==. & beans==. & eggs==. & milk==.
recode protein 2=1 3/4=2 5/6=3, gen(prot_cat)
egen diettot=rowtotal(meals2days_cat mealsnorm_cat veg_cat prot_cat)
replace diettot=. if meals2days_cat==. & mealsnorm_cat==. & veg_cat==. & prot_cat==.
replace diettot=diettot-1 if foodenough==1 /*minus 1 from dietscore if reported time with not enough food in last year*/
egen dietposs=rownonmiss(meals2days_cat mealsnorm_cat veg_cat prot_cat)
gen dietscore1=diettot/(dietposs*3) /*average of all possible diet scores*/
foreach y in `yearlist' { /*make relative dietscore by year - so diets only compared with diets from same era*/
cap xtile dietscorey`y'=dietscore1 if year==`y', nq(10) /*score is created by splitting the population into deciles*/
if _rc~=0 gen dietscorey`y'=.
}
egen dietscore=rowmax(dietscorey*)