Hello,
I am trying to calculate a variety of CAARs for my dataset. I already have calculated the average abnormal returns in the following manner:

bysort acquirer_nationb dif : egen AARAN=mean(abnormal_return)

bysort target_nationb dif : egen AARTN=mean(abnormal_return)

bysort acquirer_sectorb dif : egen AARAS=mean(abnormal_return)

bysort target_sectorb dif : egen AARTS=mean(abnormal_return)

bysort acquirer_industryb dif : egen AARAI=mean(abnormal_return)

bysort target_industryb dif : egen AARTI=mean(abnormal_return)

bysort domestic dif : egen AARD=mean(abnormal_return)

bysort same_sectorb dif : egen AARSS=mean(abnormal_return)

bysort same_industryb dif : egen AARSI=mean(abnormal_return)

bysort transaction_directionb dif : egen AARTD=mean(abnormal_return)

bysort volume_quartile dif : egen AARVQ=mean(abnormal_return)

bysort payment_methodb dif : egen AARPM=mean(abnormal_return)


So, here I calculated the AAR for each observation depending on different groups (calculated the average for all from country a or b, calculated the average for all with payment type or b etc)

Now I have the individual AAR for each date and want to add them up in order to obtain the CAAR.

For example, in order to obtain the CAAR for the acquirer nation I tried it with . bysort acquirer_nationb dif : egen caarsan = sum(AARAN)

. bysort acquirer_nationb (dif) : egen caarsani = sum(AARAN).

Now, lets say for example I have 5 observations for acquiring country a. In my database each observation therefore has the same value for AAR on day t. Now if I type this code, I have the problem that caarsan adds the average 5 times for each (since I have 5 observations for the country) while the caarsani code gives me for each t the sum of the averages.
However, I really want a combination of both. I want the sum of all averages but every average only counted once. Can anybody provide me with some help on how to do that? Im attaching a picture