Hi, as this is my first post, I hope I meet all the criteria.
I am using a large panel data set on acquisitions of firms over many years. Hereby I am concerned about the premium a firm pays (i.e. the price above the market cap prior to the acquisition - btw. it is not important to understand the concept here) to acquire another. I run into multiple occasions, where a firm, lets say firm A acquires firm B and firm C both in a year, say 1999. I now would like to take the average of the premium paid, however not just the normal average (for which I understand I could use the collapse command), but a weighted average. As I understand it, the collapse command can also use weighted averages, however - if I am not mistaken- only when one takes on of the variables on which you identify the duplicates as the weight. I however, would like to take the Deal_value as the weight, a variable which is not used for the collapse command (i.e. I only want to consider Year and Firm ID for duplicates). Is there any way how I can get the variable that I need? Either using the collapse command or another?

Here an example:
Firm Year Deal Value Acquisition Premium
A 1999 2.000.000 10%
A 1999 8.000.000 15%
I want stata to give me the value of WAVR_Acquisition_Premium = 14% for Firm A in the Year 1999.
I hope I made everything clear enough. Thank you in advance for your help.