Dear Stata team,

I would appreciate it if someone could shed some light on my query below:

I have multiple observations per ID. One of my variables (days_unregistered) always has the highest value for example see table below. I wish to extract the highest number of the day_unregisterd and divide it with the total_appointments. So for ID 5 I wanted to divide 1000/10, ID 4 2000/9, ID 3 900/4 , ID 2 100/2, ID 1 80/1 ans so on.
What is the best way to do this please?

thank you very much,
Maria
ID Days_unregistered total_appointments
5 1000 10
5 950 10
5 850 10
4 2000 9
4 500 9
3 900 4
3 5 4
2 100 2
2 6 2
1 80 1
1 60 1