Announcement

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

  • Eventstudy2 command issue with merging datastets

    Dear statalist,
    I am trying to use the estudy2 command

    This is the command I run
    eventstudy2 set date using security_returns, returns(security_returns) model(MA) marketfile(security_returns) marketreturns(market_return)

    Stata issued the error message hereafter ;

    Generating dateline ...
    ...succeeded
    Preparation of event list ...
    ...succeeded
    Preparation of security return data...
    ...succeeded
    Preparation of market and/or factor return data...
    ...succeeded
    set is int in using data
    r(106);


    The error seems to say that the variable set is not on the right format in one of the dataset however it is in numeric in the two datastet.

    Here are the 2 datastets

    ----------------------- copy starting from the next line -----------------------
    [CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str13 company_id str10 DATE int set long date
    "FR0000121261" "17/06/2009" 1 18065
    "FR0000120271" "10/03/2009" 2 17966
    "FR0000120271" "30/06/2009" 3 18078
    "FR0000031122 " "13/02/2009" 4 17941
    "FR0000031122 " "15/04/2009" 5 18002
    "FR0000031122 " "04/09/2009" 6 18144
    "FR0000120073" "18/10/2009" 7 18188
    "FR0010313833" "22/10/2009" 8 18192
    "FR0000130007" "11/02/2009" 9 17939
    "FR0000071946" "18/10/2009" 10 18188
    "AT0000837307." "26/05/2009" 11 18043
    "FR0000034639" "18/06/2009" 12 18066
    "LU0323134006 " "07/04/2009" 13 17994
    "FR0000051732" "18/02/2009" 14 17946
    "FR0000035164" "02/04/2009" 15 17989
    "FR0000121568" "26/06/2009" 16 18074
    "FR0000131757" "05/08/2009" 17 18114
    "FR0000121147" "05/02/2009" 18 17933
    "FR0004076891" "06/03/2009" 19 17962
    "FR0000133308" "04/03/2009" 20 17960
    "FR0000063935" "27/08/2009" 21 18136
    "US37045V1008" "04/09/2009" 22 18144
    "FR0004061513" "23/01/2009" 23 17920
    "FR0000121485" "11/02/2009" 24 17939
    "FR0000052680" "05/02/2009" 25 17933
    "FR0000120321" "17/02/2009" 26 17945
    "FR0011476928" "18/02/2009" 27 17946
    "FR0000121485" "05/10/2009" 28 18175
    "FR0000038606" "05/04/2009" 29 17992
    "FR0000032278" "16/09/2009" 30 18156
    "FR0000121014" "06/02/2009" 31 17934
    "FR0000064941" "15/06/2009" 32 18063
    "FR0000044448 " "22/04/2009" 33 18009
    "FR0010240994" "13/02/3009" 34 383183
    "FR0000053514" "16/04/2009" 35 18003
    "FR0000051377" "25/03/2009" 36 17981
    "FR0010479956" "20/03/2009" 37 17976
    "FR0000064255" "31/01/2009" 38 17928
    "FR0000125007" "08/09/2009" 39 18148
    "FR0000073272" "09/07/2009" 40 18087
    "FR0000120578" "30/06/2009" 41 18078
    "AN8068571086" "23/03/2009" 42 17979
    "FR0000121972 " "29/01/2009" 43 17926
    "FR0000121709" "11/02/2009" 44 17939
    "FR0000063364" "27/07/2009" 45 18105
    "FR0013227113" "02/04/2009" 46 17989
    "FR0000131732" "29/01/2009" 47 17926
    "FR0000054199" "16/06/2009" 48 18064
    "FR0000121329 " "01/07/2009" 49 18079
    "DE0007500001" "23/02/2009" 50 17951
    "FR0000051807" "16/06/2009" 51 18064
    "FR0013176526" "15/01/2009" 52 17912
    "FR0000077570" "09/01/2009" 53 17906
    "FR0010759530" "16/05/2009" 54 18033
    "FR0000120271" "21/01/2010" 55 18283
    "FR0013018124" "01/12/2010" 56 18597
    "FR0000035784" "23/02/2010" 57 18316
    --more--



    ----------------------- copy starting from the next line -----------------------
    [CODE]
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(event_obs tradeday) str10(event_date date_l) int(set day) double price int(date day2) str10 date_market double(market security_returns market_return) str61 name str13 company_id float group_id
    0 1 "17/06/2009" "10/10/2008" 1 1 582.5800170898438 17815 1 "10/10/2008" 3697.090087890625 . . "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 2 "17/06/2009" "13/10/2008" 1 2 653.6300048828125 17818 2 "13/10/2008" 4094.969970703125 .12195747486823194 .10761974237947514 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 3 "17/06/2009" "14/10/2008" 1 3 657.1799926757813 17819 3 "14/10/2008" 4212.18017578125 .005431188541604959 .02862297059970853 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 4 "17/06/2009" "15/10/2008" 1 4 611.4199829101563 17820 4 "15/10/2008" 3931.300048828125 -.06963086258805296 -.066682837682989 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 5 "17/06/2009" "16/10/2008" 1 5 585.5599975585938 17821 5 "16/10/2008" 3704.97998046875 -.042294962667849934 -.057568759837305805 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 6 "17/06/2009" "17/10/2008" 1 6 589.6099853515625 17822 6 "17/10/2008" 3857.8798828125 .006916435224152195 .04126875263828156 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 7 "17/06/2009" "20/10/2008" 1 7 611 17825 7 "20/10/2008" 3986.0400390625 .03627824355057929 .03322035940542767 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 8 "17/06/2009" "21/10/2008" 1 8 621.0900268554688 17826 8 "21/10/2008" 4017 .016513955573598693 .007767097328199801 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 9 "17/06/2009" "22/10/2008" 1 9 585.7100219726563 17827 9 "22/10/2008" 3822.679931640625 -.05696437449163172 -.04837442578027762 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 10 "17/06/2009" "23/10/2008" 1 10 534.8400268554688 17828 10 "23/10/2008" 3827.719970703125 -.08685184341879393 .0013184569863626816 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 11 "17/06/2009" "24/10/2008" 1 11 496.260009765625 17829 11 "24/10/2008" 3686.260009765625 -.07213375056588522 -.036956716275019175 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 12 "17/06/2009" "27/10/2008" 1 12 456.260009765625 17832 12 "27/10/2008" 3541.489990234375 -.08060290817890259 -.03927287254499845 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 13 "17/06/2009" "28/10/2008" 1 13 469.1199951171875 17833 13 "28/10/2008" 3596.139892578125 .02818565089271896 .01543133045538636 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 14 "17/06/2009" "29/10/2008" 1 14 507.9800109863281 17834 14 "29/10/2008" 3908.340087890625 .08283598284791349 .08681536442918492 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 15 "17/06/2009" "30/10/2008" 1 15 548.97998046875 17835 15 "30/10/2008" 3928.169921875 .08071177722685108 .005073722741225861 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 16 "17/06/2009" "31/10/2008" 1 16 570 17836 16 "31/10/2008" 4017.610107421875 .03828922780262767 .02276891970706374 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 17 "17/06/2009" "03/11/2008" 1 17 565.739990234375 17839 17 "03/11/2008" 4067.10009765625 -.0074737013432018 .012318266061445371 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 18 "17/06/2009" "04/11/2008" 1 18 616.5399780273438 17840 18 "04/11/2008" 4252.89013671875 .0897938782300387 .04568120641278672 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 19 "17/06/2009" "05/11/2008" 1 19 631.3900146484375 17841 19 "05/11/2008" 4170.10986328125 .0240860887376797 -.01946447492795278 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 20 "17/06/2009" "06/11/2008" 1 20 580.3099975585938 17842 20 "06/11/2008" 3908.260009765625 -.08090089470022022 -.06279207553289457 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 21 "17/06/2009" "07/11/2008" 1 21 578.739990234375 17843 21 "07/11/2008" 3994.10009765625 -.0027054631676585172 .021963760772347518 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 22 "17/06/2009" "10/11/2008" 1 22 591.030029296875 17846 22 "10/11/2008" 4040.75 .021235855945470172 .011679702862510632 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 23 "17/06/2009" "11/11/2008" 1 23 546.2000122070313 17847 23 "11/11/2008" 3860.070068359375 -.07585065879508057 -.044714454405896165 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 24 "17/06/2009" "12/11/2008" 1 24 525.5999755859375 17848 24 "12/11/2008" 3751.1298828125 -.03771518886983383 -.02822233369281224 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    0 25 "17/06/2009" "13/11/2008" 1 25 528.0900268554688 17849 25 "13/11/2008" 3780.0400390625 .004737540687203001 .0077070528489202594 "CMPG.DES ETS.MICH. - TOT RETURN IND" "FR0000121261" 90
    --more--


    Thanks a lot of your help,

    Najiba

  • #2
    Numbers are stored as byte, int, long, float, or double. To change the storage type of set to int,
    Code:
    recast int set

    Comment


    • #3
      Thank you very much for your answer.
      I tried the command, however it doesn't work and I have the same error message. When i run the command describe set in the two datastets the variable set is stored as "int" in both but the format is different (%10.0g in the first and %8.0g in the second) . Could it explain the issue ?

      Thanks a lot

      Comment


      • #4
        Possibly, to change the format to, e.g., %10.0g,
        Code:
        format %10.0g variable

        Comment


        • #5
          Thank you for your answer, however I tried but I didn't work.

          Comment


          • #6
            I am sorry to hear that. Did you get the same error message? It worked for me.
            First, I save the second dataex example as security_returns. The variable set is type int format %8.0g and the variable date is long format %12.0g.
            Second, I load the first dataex example in Stata. The variable set is type int format %8.0g and the variable date is long format %8.0g.
            Third, I run your code,
            Code:
            eventstudy2 set date using security_returns, returns(security_returns) model(MA) marketfile(security_returns) marketreturns(market_return)

            Comment


            • #7
              Thank you for very much for trying again, unfortunatly I tried again and yes I got the same error message :


              . eventstudy2 set date using sr, returns(security_returns) model(MA) marketfile(sr) m
              > arketreturns(market_return)
              Generating dateline ...
              ...succeeded
              Preparation of event list ...
              ...succeeded
              Preparation of security return data...
              ...succeeded
              Preparation of market and/or factor return data...
              ...succeeded
              set is int in using data
              r(106);


              However I checked for each dataset the storage is int for the variable set for both datatsets :

              describe set (security_return dataset)

              storage display value
              variable name type format label variable label
              -------------------------------------------------------------------------------------
              set int %8.0g



              describe set (first dataset)

              storage display value
              variable name type format label variable label
              -------------------------------------------------------------------------------------
              set int %8.0g








              Comment


              • #8
                Dear both,

                This is Thomas, author of eventstudy2.

                Could you please rename the varibale "set" to something else in both datasets and retry? "set" is used internally by eventstudy2, though only as a local/tempvar but it might collide with your varname and thus be responsible for the issue.

                Best
                Thomas

                Comment


                • #9
                  Hello, Thank you very much for your answer . I tried to rename the variable set to sec_id. Unfortunatly it didn't work, I still have the message hereafter :


                  . eventstudy2 sec_id date using SRSET, returns(security_returns) model(MA) marketfile
                  > (SRSET) marketreturns(market_return)
                  Generating dateline ...
                  ...succeeded
                  Preparation of event list ...
                  ...succeeded
                  Preparation of security return data...
                  ...succeeded
                  Preparation of market and/or factor return data...
                  ...succeeded
                  sec_id is int in using data

                  Best regards,
                  Najiba

                  Comment

                  Working...
                  X