Hi Statalist users

I have a panel data set in which respondents (persnr) did state their annual income. I was interested in the highest income they ever obtained shown in the observations. For this purpose I used the max function (egen max_inc= max(inc)). But of course now I am interested at which age they actually earned the most.

here is my data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 A str10 B str3 C str7 D
"persnr" "survey_age" "inc" "max_inc"
"2402"   "46"         "256" "665"    
"2402"   "47"         "488" ""      
"2402"   "48"         "665" ""      
"2403"   "20"         "716" "716"    
"2403"   "21"         "716" ""      
end
So for the person 2402 the max_age should be 48 and for the case of 2403 I would prefer the first year in which the person earned 716 - so it would be 20
Do you have any idea which code would suit best?

Thanks a lot

Jessica