Hi Statalist Experts,
I am trying to do the following (see below) with my data, but unfortunately I am not able to implement it. Unfortunately, there is no unique identifier to merge two datasets, since throughout the time period the stocks and their personal permno code appear several times. I hope you can help me how to edit my data. I want to do the following:
Please note that MktCap is not included in the sample data, since my calculation was wrong (as stated above). Thank you very much for your help!
Best,
Guest
I am trying to do the following (see below) with my data, but unfortunately I am not able to implement it. Unfortunately, there is no unique identifier to merge two datasets, since throughout the time period the stocks and their personal permno code appear several times. I hope you can help me how to edit my data. I want to do the following:
- For every stock in the data, calculate MktCap (shares outstanding (shrout) * price (altprc) ) on the last available / trading day of June in each year y and hold the value constant for the months from June of the same year y until May of year y+1, when MktCap is recalculated. Using this approach, the MktCap remains constant from any given June through the following May.
- Calculate the natural logarithm of MktCap (same rule as in bullet 1), name the variable Size
- In June of each year, compute decile breakpoints using only stocks that trade on the New York Stock Exchange (stocks, which have “1” as exchange code (see variable exchcd), and then use those breakpoints to sort all stocks in the sample (incl. stocks that trade on other exchange stocks) into 10 portfolios (e.g. 1 breakpoint = 10, data with MktCap <= 10 should go into the first portfolio)
- Compute equal-weighted monthly returns on the portfolios for the next 12 months, from July in year y to June in year y+1 for the years 1963-2016 (my whole data time period). The returns for the single stocks can you find under the variable exret.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(permno date) byte exchcd long shrout float(altprc exret) 92241 19870630 3 2411 6.25 -.022 92241 19870529 3 2411 6.25 .04483 92241 19870831 3 2420 5.75 -.043277 92241 19870430 3 2411 5.875 . 92241 19870731 3 2420 5.875 -.081 92241 19870930 3 2420 5.75 -.003609 92241 19871231 1 2570 4.6875 .275103 92241 19880331 3 2545 4.375 -.019 92241 19880129 3 2545 4.375 -.081667 92241 19880229 3 2545 4.375 -.023 92241 19880429 3 2545 4.125 -.080143 92241 19871030 1 2570 4 -.331348 92241 19880531 3 2545 4 -.054303 92241 19871130 3 2570 3.625 -.11075 67619 19811030 1 10739 3.3125 .178558 67619 19810630 3 12247 2.6875 -.04 67619 19811130 3 10739 2.6875 -.241679 67619 19810930 1 10739 2.6875 -.03519 67619 19810630 3 8989 2.625 .074135 66966 19831230 3 3945 6.375 .074696 67619 19820129 3 12247 2.6875 -.04 67619 19810430 3 8989 2.75 .243118 end
Best,
Guest
Comment