Hello - I'm attempting to create a variable (totalsharesheld) that is the aggregate of three different funds' holdings in a given company for each quarter. I'm getting close with

egen totalsharesheld = total(sharesheld & month(holdingdate) & year(holdingdate), by(company)

but am not getting a number that aggregates the three investors' holdings for, say, filings from December 2012 (as dataex affected the holdingdate, I've attached a screenshot as well).

Trying to get a number that is an aggregate of the different funds' holdings for a given month in a different year. Any help is appreciated. Thanks!


input str40 index str5 ticker str34 fundname double (fundid companyid holdingdate sharesheld percentportfolio percentsharesoutstanding shareschanged percentshareschanged) str50 company double(year CoG SGA RD Cap Buyback) float(LME CME MME)
"FTSE Taiwan Index" "3105" "BlackRock, Inc." 403413 2482606 19173 23909 0 .00658 -10010 -29.51 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "The Vanguard Group, Inc." 417222 2482606 19023 671156 0 .18474 574959 597.69 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "The Vanguard Group, Inc." 417222 2482606 19297 1356769 0 .32352 517685 61.7 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "State Street Global Advisors, Inc." 823170 2482606 19358 12233 0 .00292 -556 -4.35 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "State Street Global Advisors, Inc." 823170 2482606 19266 12789 0 .00352 12789 . "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "BlackRock, Inc." 403413 2482606 19358 1255720 0 .29942 1231811 5152.0 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "The Vanguard Group, Inc." 417222 2482606 19113 741218 0 .204 70062 10.44 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "The Vanguard Group, Inc." 417222 2482606 19205 839084 0 .23092 97866 13.2 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "BlackRock, Inc." 403413 2482606 19264 23909 0 .00658 0 0 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "BlackRock, Inc." 403413 2482606 19082 33919 0 .00934 -5004 -12.86 "WIN" 2012 225.7 25.9 17 75 0 0 1 0
"FTSE Taiwan Index" "3105" "The Vanguard Group, Inc." 417222 2482606 19389 1454634 0 .34433 97865 7.21 "WIN" 2013 256.6 17.5 17.3 128.3 0 0 1 0
"FTSE Taiwan Index" "3105" "State Street Global Advisors, Inc." 823170 2482606 19723 14457 0 .00346 0 0 "WIN" 2013 256.6 17.5 17.3 128.3 0 0 1 0
"
Array