Announcement

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

  • Stata crashes during second eventstudy2 run – stuck at “Merging event dates and stock market data”

    Hi everyone,

    I'm currently using the eventstudy2 command in Stata for my thesis, and I've run into a problem I’m hoping someone here has encountered before.

    My setup involves running five separate event studies. Each study uses its own dataset, event list, and market return file. The first run works perfectly and completes without issue. However, when I attempt to run the second study, Stata gets stuck at the message:

    Merging event dates and stock market data...


    It eventually freezes or crashes completely. The strange thing is:
    • I’m using the same code (adjusted only for the file paths)
    • The second dataset is smaller in size (62 events)
    • I've already tried clear all, restarting Stata, and running on two different computers
    I'm fairly new to Stata, so it's possible I'm missing something obvious, but I wanted to ask:
    Has anyone experienced eventstudy2 freezing at the merge step?
    If so, how did you resolve it?

    I've attached the code I'm using below — but again, it works fine for the first country, which makes me think the issue may be something else.

    Any advice or ideas would be incredibly appreciated!

    Thank you so much in advance

    Code:
    use "\\uwfpcluster03.uw.lu.se\ag5840be-s$\Desktop\Thesis\Norway\event_date_norway.dta"
    
     cd "\\uwfpcluster03.uw.lu.se\ag5840be-s$\Desktop\Thesis\Norway"
     
    eventstudy2 firmid date using "\\uwfpcluster03.uw.lu.se\ag5840be-s$\Desktop\Thesis\Norway\stock_data_norway.dta", returns(ri) model(MA) marketfile(mkt_norway) marketreturns(mkt) evwlb(-3) evwub(3) eswlb(-210) eswub(200) minevw(7) minesw(200) car2LB(-2) car2UB(2) car3LB(-1) car3UB(1)
    Last edited by Agnes Berglund; 04 Apr 2025, 10:02.

  • #2
    I doubt this will be possible to figure out without at least a trace of the program around the point that it gets stuck.

    I would do something like
    Code:
    set tracedepth 2
    set trace on
    just before calling eventstudy2, and then show us the output from the point around which it gives you the message about merging event dates.

    Also, as you are requested to state (see the FAQ): eventstudy2 is a community-contributed command available via ssc install eventstudy2

    Comment


    • #3
      Okay, thank you, I have now tried using that command and here is the output from where it says merging event dates:

      Code:
       Merging event dates and stock market data...
        - use "`__Eventdates.dta'", clear
        = use "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.000005", clear
        - bysort `1': gen `set'=_n
        = bysort firmid: gen __000008=_n
        - capture sort `1' `set'
        = capture sort firmid __000008
        - if _rc == 111{
          di as error "Please ensure that at least some of your security returns and factor returns cover the event period; probably your security return data and/or 
      > market return data spans a time period that is different from the time period of your events."
          exit = 111
          }
        - capture: tostring `idmarket', replace
        = capture: tostring , replace
        - tempfile __Eventdates_set
        - save "`__Eventdates_set'", replace
        = save "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000b", replace
        - count
        - scalar `NoEventsTotal' = r(N)
        = scalar __00001V = r(N)
        - bysort `1': gen `eventcount'=_N
        = bysort firmid: gen __000009=_N
        - by `1': keep if _n==1
        = by firmid: keep if _n==1
        - keep `1' `eventcount'
        = keep firmid __000009
        - tempfile __Eventcount
        - save "`__Eventcount'"
        = save "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000c"
        - use "`__Stockdata'", clear
        = use "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000a", clear
        - merge m:1 `1' using "`__Eventcount'", nogen keep(2)
        = merge m:1 firmid using "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000c", nogen keep(2)
        - capture: levelsof `1', local(Noreturns) separate(,)
        = capture: levelsof firmid, local(Noreturns) separate(,)
        - keep `1'
        = keep firmid
        - tempfile __SecurityWithNoReturns
        - save "`__SecurityWithNoReturns'"
        = save "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000d"
        - use "`__Stockdata'", clear
        = use "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000a", clear
        - erase "`__Stockdata'"
        = erase "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000a"
        - sort `1'
        = sort firmid
        - merge m:1 `1' using "`__Eventcount'", nogen keep(3)
        = merge m:1 firmid using "/var/folders/5w/1db0wjsd3nd40dsdjdk1j3bm0000gn/T//S_81736.00000c", nogen keep(3)
        - compress
        - expand `eventcount'
        = expand __000009
        - drop `eventcount'
        = drop __000009
        - bysort `1' `2': gen `set'=_n
        = bysort firmid date: gen __000008=_n

      Comment


      • #4
        Please send both event_date_norway.dta and stock_data_norway.dta which cause the isssue to us at [email protected]

        if you are using Stata 17 or 18, try the following as well, before running your commands, type:

        Code:
        set sortmethod qsort
        then run your commands to see if that makes any difference.

        Comment

        Working...
        X