# Find corresponding value to extreme score

#### leonedelman

##### New Member
Hi, I have data that look something like:
id score1 score2 score3 year1 year2 year3
5 90 42 64 2000 2001 2002
6 50 50 80 1996 1997 1998
7 76 98 85 2005 2006 2007

For each id I want to identify the highest score and then find the year it occurred. I want to make two columns, one for the highest score and one for the corresponding year. For id7, the return values would be a score of 98 and the year 2006. here is what I did but I don't know how to make it run for all id's. thank you!

Code:
Code:
egen HighestScore = rowmax(score1 score2 score3)

forvalues j = 1/3 {
gen YearHighestScore = yearj' if HighestScore == scorej'