Hi, I'm new to Stata so apologies if my question seems a bit 'simple'. I'm currently researching the relationship between earnings management and institutional ownership. I was able to calculate the earnings aspect, but i have trouble with my 'investor turnover' formula. I'm supposed to do the following:
A short-term investor should buy and sell his investments frequently, while a long-term investor should hold his positions unchanged for a considerable length of time. To implement this idea empirically, i calculate for each institutional investor a measure of how frequently he rotates his positions on all the stocks of his portfolio (churn rate). If we denote the set of companies held by investor i by Q, the churn rate of investor i at quarter t is Array



where Pj,t and Nj,i,t represent the price and the number of shares, respectively, of company j held by institutional investor i at quarter t.

I then use investor churn rates to construct a measure of investor turnover for the firm that measures the investment horizon of institutional shareholders in the firm prior to an acquisition announcement. Denote by S the set of shareholders in company k and by wk,i,t the weight of investor i in the total percentage held by institutional investors at quarter t. The investor turnover of firm k is the weighted average of the total portfolio churn rates of its investors over four quarters: Array



The data is panel data with multiple companies over a time frame of 15 years (2003-2017). I'm having a hard to even start with transforming these formulas into STATA code. Is there anyone who could help me with this? I have attached a small example of my data set below:
File Date Manager Name Manager Number Type Code Report Date Prior Report Date Cusip Shares Held at End of Qtr Net Change in Shares Since Prior Report Stock Name Industry Code Share Price, as of FDATE Shares Outstanding in Millions, as of FDATE
20030331 AIM MANAGEMENT GROUP, INC. 140 5 20030331 20021231 13442910 3178798 616256 CAMPBELL SOUP CO 115 21 410
20030331 ASB CAPITAL MANAGEMENT, INC. 185 5 20030331 20021231 13442910 312934 -300 CAMPBELL SOUP CO 115 21 410
20030331 ADVEST BANK AND TRUST COMPANY 488 1 20030331 20021231 13442910 1200 CAMPBELL SOUP CO 115 21 410