Dear All:
I have a dataset with 3 variables. I want to pick the highest 3 values from one column then want to have average of those 3 values.
For example:
gvkey year return
11 1990 10
11 1990 11
11 1990 12
11 1990 8
12 1990 6
12 1990 5
12 1990 4
12 1990 8
13 1990 22
13 1990 20
13 1990 21
11 1991 15
11 1991 14
11 1991 13
11 1991 10
Now I want to have for gvkey 11 and year 1990 the maximum values such as 10, 11, and 12 and want have the average (10+11+12)/3=11.
Please let me know which stata command I should use.
Thank you.
I have a dataset with 3 variables. I want to pick the highest 3 values from one column then want to have average of those 3 values.
For example:
gvkey year return
11 1990 10
11 1990 11
11 1990 12
11 1990 8
12 1990 6
12 1990 5
12 1990 4
12 1990 8
13 1990 22
13 1990 20
13 1990 21
11 1991 15
11 1991 14
11 1991 13
11 1991 10
Now I want to have for gvkey 11 and year 1990 the maximum values such as 10, 11, and 12 and want have the average (10+11+12)/3=11.
Please let me know which stata command I should use.
Thank you.
Comment