Announcement

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

  • Matching dates

    Hi all,

    I need the iv_spread value of option expiration date (exdate) closest (during or after) to the announcement date (anndats_act). How do I get the minimum value of the gap variable (difference between expiration date of an option and earnings announcement date) in the following dataset? I tried "bysort cusip date: keep if min(gap)" but stata says the syntex is invalid.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(date exdate) str8 cusip float(option_duration iv_spread) double(analys value actual) long anndats_act float(gap nearest)
    13158 13168 "03783310" 10 -.076504     54   -.02 -.02 13165  3 13168
    13158 13168 "03783310" 10 -.188772   9486 -.0196 -.02 13165  3 13168
    13158 13168 "03783310" 10 -.188772     54   -.02 -.02 13165  3 13168
    13158 13168 "03783310" 10 -.173916     54   -.02 -.02 13165  3 13168
    13158 13168 "03783310" 10 -.115971     54   -.02 -.02 13165  3 13168
    13158 13168 "03783310" 10  .042142     54   -.02 -.02 13165  3 13168
    13158 13168 "03783310" 10 -.021389 635404 -.0196 -.02 13165  3 13168
    13158 13196 "03783310" 38  .000501   1997 -.0196 -.02 13165 31 13168
    13158 13196 "03783310" 38 -.030153     54   -.02 -.02 13165 31 13168
    13158 13196 "03783310" 38 -.022294 500064 -.0196 -.02 13165 31 13168
    end
    format %d date
    format %d exdate
    format %d anndats_act
    Kind regards,

    Frank



  • #2
    You have different spreads (iv_spread) for the same firm (cusip) and date. What is your rule for selecting one over the other? If it matters not, then the sort order determines the minimum gap, but this is arbitrary if this gap is not unique.

    Code:
    bysort cusip date (gap): keep if _n==1

    Comment

    Working...
    X