Derivation
variable: maizesell (table[s]: css_seh)
variable: ricesell (table[s]: css_seh)
variable: gnutsell (table[s]: css_seh)
variable: harvesttot (table[s]: temporary derived variable)
<Cans of harvest sold is added together and then turned into a decile variable in relation to all other records with this data within the same year>
egen selltot=rowtotal(maizesell ricesell gnutsell)
replace selltot=. if maizesell==. & ricesell==. & gnutsell==.
replace selltot=harvesttot if selltot>harvesttot & selltot~=. & harvesttot~=. /*in a few case amount sold is greater than amount harvested*/
gen harvselltot=int(10*(selltot/harvesttot)) if harvesttot>0 & harvesttot~=. & selltot~=. & selltot<=harvesttotforeach var in plot harvest harvsell {
foreach y in `yearlist' { /*make relative score by year*/
cap xtile `var'scorey`y'=`var'tot if year==`y', nq(10) /*score is created by splitting the population into deciles*/
if _rc~=0 gen `var'scorey`y'=.
}
egen `var'score=rowmax(`var'scorey*)
drop `var'scorey*
}