Announcement

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

  • Event window and estimation window ERROR

    Dear Statalist,

    I'd really appreciate any help members have to offer with my problem.

    I'm running an event study on the princeton method (http://dss.princeton.edu/online_help...ventstudy.html). I've successfully merged my market data , with 316 events over 8 years.
    My event window is (-5;-2) and estimation window is (-205;-6)

    I used the following codes:

    sort company_id date
    by company_id: gen datenum=_n
    by company_id: gen target=datenum if date==event_date
    egen td=min(target), by(company_id)
    drop target
    gen dif=datenum-td

    by company_id: gen event_window=1 if dif>=-5 & dif<=-2
    egen count_event_obs=count(event_window), by(company_id)
    by company_id: gen estimation_window=1 if dif<-6 & dif>=-205
    egen count_est_obs=count(estimation_window), by(company_id)
    replace event_window=0 if event_window==.
    replace estimation_window=0 if estimation_window==.
    tab company_id if count_event_obs<4
    tab company_id if count_est_obs<200
    drop if count_event_obs < 4
    drop if count_est_obs < 200

    However, both my event and estimation window turned out to be all 0. Therefore, when I used the drop command, there is no value lelf.
    Is there any problem with my code.
    Thank you in advance.

    Click image for larger version

Name:	stata.png
Views:	1
Size:	174.1 KB
ID:	1456640

  • #2
    Please read the Forum FAQ for excellent advice about posting in ways that maximize your chances of getting a timely and helpful response. In particular, pay attention to #12 concerning how to show example data. Of all the ways to show example data, screen shots are the least effective. First, as in this case, they often turn out unreadable on some members' computers. Second, even when readable, they do not contain metadata that is often crucial to correct code. Third, even when there are no metadata issues, it is impossible to import data into Stata from a screen shot, so there is no way to see what the dysfunctional code is doing or test ways to correct it.

    Please post back showing an example of your data by using the -dataex- command. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X