Announcement

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

  • 8 character date

    Hi,
    I need an 8 character date in order to use the "estudy" package (it's for the "evdate" option).

    When i format my date using below command, it shows the date i want in the data editor, but when i highlight the cell and look at the value bar, it displays 9 characters.

    format %tdNNDDCCYY eventdate

    In short, i need dates stored as 03032006 (which is 8 characters) instead of 03mar2006 (which is 9 characters).

    I have tried illustrating the problem in the below image. As you can see, i have also tried to format the variable as a string and then manually replacing all the month names using below command, but "estudy" only accepts date variables.

    replace eventstring = subinstr(eventstring,"jan","01",.)
    replace eventstring = subinstr(eventstring,"feb","02",.)
    etc..

    Any advice?

    Click image for larger version

Name:	date stata.png
Views:	1
Size:	59.7 KB
ID:	1595794

  • #2
    Code:
    di %td 16863
    di  %tdDDNNCCYY  16863
    Res.:

    Code:
    . di %td 16863
    03mar2006
    
    .
    . di  %tdDDNNCCYY  16863
    03032006
    Implies:

    Code:
    gen wanted= string(date, "%tdDDNNCCYY")
    You cannot have leading zeros in numbers, so your wanted variable has to be a string. Sorry, I cannot help with specifics of your problem, but Stata dates are SIF values and should be recognized by commands that accept dates as input.
    Last edited by Andrew Musau; 02 Mar 2021, 05:51.

    Comment


    • #3
      In the estudy command, the argument to the evdate() option is not a variable name - it is a fixed date value which will be the same for every observation, and the dateformat() option describes the format in which the date specified by evdate() is presented. Here is an example presented in the output of the help estudy command with my highlights in red.
      Code:
      Perform an event study on two varlists with two event windows around 09 July 2015.
      ARs are reported with four decimals.
          . estudy boa ford boeing (apple netflix amazon facebook google), datevar(date)
              evdate(07092015) dateformat(MDY) lb1(-1) ub1(1) lb2(-3) ub2(3) indexlist(mkt)
              decimal(4)
      Last edited by William Lisowski; 02 Mar 2021, 07:32.

      Comment


      • #4
        Thank you for your replies. The evdate() option for estudy is applicable using a namelist variable along with a datelist variable, but I've come to the realization that i have to use "eventstudy2" as i have multiple events per firm which estudy does not allow. Estudy allows for 1 event per firm, which is a dealbreaker in relation to my data set where i have in the area of 92.000 events from 500 firms. So, if anyone reaches this thread and seeks to use estudy on such a dataset, please refer to the "eventstudy2" package.

        Comment

        Working...
        X