Dear Stata Community,

Iam almost new to stata and Iam kind of stuck with a problem. May someone can help.

The general task iam doing is to keep the 95 richest occupations out of my 430 in total. Therefor I need the average Income by each occupation.
To do it single handly for each occupation would cost alot of time and creates a huge code with the same and repeating commands.

mean "wage-variable" if "occuaption-variable" == "teacher"

I would like to say stata to search in my occupation variable for each individual occupation and to calculate the mean. After that I want stata to keep the 95 highest ones in a list.

Thanks in advance,
Moritz