Derivation
variable: plotsow (table[s]: css_seh, gp_gphhold)
variable: plotsrentd (table[s]: css_seh, gp_gphhold)
variable: plotslet (table[s]: css_seh, gp_gphhold)
variable: plotsfall (table[s]: css_seh, gp_gphhold)
variable: plotsother (table[s]: css_seh, gp_gphhold)
<Number of plots is added together and then turned into a decile variable in relation to all other records with this data within the same year>
egen plottot=rowtotal(plotsow plotsrentd plotslet plotsfall plotsother)
replace plottot=. if plotsow==. & plotsrentd==. & plotslet==. & plotsfall==. & plotsother==.
foreach 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*
}