Hello everyone

I am a thesis student from Belgium working on my thesis about labour market concentration. For my research, I need to calculate the HHI for multiple observations. Below, you find an example of the data which I have to use. The NACE Code represents the sector. I need to calculate the HHI for each NACE code and for each year. So for code 1 I need to have a result for all the years in a range from 1985 until 2014, and so on. Every row in the table represents one firm. So in my dataset there are multiple rows of data for the same NACE Code and year.
NACE Code YEAR EMPLOYEES
1 1985 14
1 2010 5
2 1999 88
14 2000 79
15 1987 3
27 1992 45
45 2014 777
66 1998 23
97 2000 14
I already read some helpful posts on this forum about the HHI. For example, I tried to use the entropyetc command. However, I have a lot of data. In total, my dataset consists of 7,5 million rows of data. If I use the collapse command to decrease the amount of rows, I get the same problem of having to much rows of data.
One thing I was thinking as a solution was working with some kind of loop command so that I can loop the same command for the whole dataset. However, I don't really know how to do this. I've tried some things so far but none of them have given me the desired result. I was wondering if anyone can help me out with this problem?

Thank you in advance!
Kind Regards
Robin Naessens