Announcement

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

  • Return for previous year with daily data

    Hi everybody,

    i have panel data with gaps in the time variable (weekends, holidays).
    I want to calculate the return of the previous year for every given day in the dataset.
    That means i want to calculate the return from e.g. the 15th of june 2003 to 16 of june 2002, which are around 260 trading days.
    But the trading days differ - sometimes there are 260, 261...

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float date int ID float(price logret)
    15341 1 6050.426           .
    15342 1 6100.735  .008280506
    15343 1 6454.218   .05632468
    15344 1 6590.232  .020854706
    15347 1 6624.453  .005179205
    15348 1 6434.162 -.029146196
    15349 1  6317.52 -.018294971
    15350 1 6145.852  -.02754934
    15351 1 6148.076 .0003619038
    15354 1 5797.756  -.05866829
    15355 1 5872.549  .012817914
    15356 1 5408.614  -.08229601
    15357 1 5641.086   .04208385
    15358 1 5816.607    .0306405
    15361 1 5816.607           0
    15362 1 6743.359   .14784098
    15363 1 6691.085 -.007782042
    15364 1 7279.668    .0843092
    15365 1 7436.516  .021317156
    15368 1 7838.474   .05264171
    end
    format %td date
    Does anybody have an idea how to manage this problem?

    Thanks

  • #2
    It would take a bunch of space, but after you xtset your data, you can refer to lags. You may also be able to do this with rangestat.

    Comment

    Working...
    X