I divided a variable in quintiles and I want to summarize a list of variables for each quintiles. I tried to use this loop but it doesn't seem to work:

xtile prof_quint = av_PSP_prof, nq(5)
tab prof_quint
order prof_quint, after (av_PSP_prof)

local quint_sum num_employees time_psp furthest_loc_time

foreach x of numlist 1/5 {
foreach y of local quint_sum {
sum `y' if prof_quint==`x'
}
}