Hi,

So I have information about how many people are holding each stock (there are about 8200 stocks in the file) and the information was hourly before, but I narrowed it down to just the day.

Below is just for one day for one stock with it's users:

date TICKER users_holding
12feb2019 ZYXI 0
12feb2019 ZYXI 1
12feb2019 ZYXI 4
12feb2019 ZYXI 6
12feb2019 ZYXI 8
12feb2019 ZYXI 9
12feb2019 ZYXI 10
12feb2019 ZYXI 12
12feb2019 ZYXI 12
12feb2019 ZYXI 12

So this is the same for all the other 8200 stocks I have in my data and I want to find the mean for each day and TICKER so that I can remove all duplicates and have it look like the below:


date TICKER users_holding
12feb2019 ZYXI 7,4


I have used this code:
Code:
bysort date date: egen holding=mean(users_holding)
But all it does is it calculates the mean for each date with no respects to the TICKER.

Anyone who can help me with creating a mean value that sorts by date and TICKER and then how I can remove those duplicates with respect to date and TICKER since I will then get:

date TICKER users_holding
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4
12feb2019 ZYXI 7,4

Thank you very much in advance!

Best regards

Mathias Sorensen