To bring in the labels:
Code:
sort year
forval sec = 1/11 {
by year: egen _wanted_`sec' = mean(avg_tuition_fees_ft) if sector==`sec'
by year: egen wanted_`sec' = max(_wanted_`sec')
local lab: label sectordf `sec'
label var wanted_`sec' `"`lab'"'
}
drop _wanted*
Comment