Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compute yearly returns from monthly returns

    Hello all,

    I am having problems aggregating my monthly return data in panelformat, so that I will end up with yearly returns for each firm instead ( taking compound interest into account)

    Currently I have my data in the following format:

    gvkey return ccmbegdt
    001004 11.8485 01jan2010
    001004 -2.47543 01feb2010
    001004 1.86637 01mar2010
    001004 1.57567 01apr2010
    001004 -5.79004 01may2010
    ....

    I want to end up having following :

    gvkey Yearly Return fyear
    001004 xxx 2010



    obs: 337,323
    vars: 3
    size: 6,071,814
    ------------------------------------------------------------------------------------------------------------------------------
    storage display value
    variable name type format label variable label
    ------------------------------------------------------------------------------------------------------------------------------
    gvkey str6 %6s Standard and Poor's Identifier
    return double %8.0g Monthly Total Return
    ccmbegdt long %d

    Thank you !!

  • #2
    Hi,
    Code:
    clear
    input str10(gvkey Return ccmbegdt)
    001004 11.8485 01jan2010
    001004 -2.47543 01feb2010
    001004 1.86637 01mar2010
    001004 1.57567 01apr2010
    001004 -5.79004 01may2010
    end
    gen date = date(ccmbegdt , "DMY")
    gen fyear = year(date)
    list  gvkey date Return fyear in 1/3

    Comment


    • #3
      You'll increase your chances of a a useful answer if you follow the FAQ on asking questions - provide Stata code in code delimiters, Stata output, and sample data.

      Are you trying to move from monthly data to yearly data? What formula do you want to use to calculate the compound interest?

      Comment

      Working...
      X