Dear experts,

I'm wondering whether you can help me. I wanted to calculate the age similarity based on below data:

1. Calculate the age difference between persons first. For example, the age difference between person 1 and person 2 is 9. the age difference between person 1 and person 3 is 1.
2. Sum the absolute age difference for person 1, which is 9+1 = 10. This absolute summed age difference is the age similarity that I want to gather for each person.
person age
1 61
1 61
1 61
2 52
2 52
2 52
3 60
3 60
3 60
So, the ideal output should be like this:
person age age similarity
1 61 10
1 61 10
1 61 10
2 52 17
2 52 17
2 52 17
3 60 13
3 60 13
3 60 13
Could you please show me how I can use Stata syntax to accomplish the two steps? Thank you very much!