Announcement

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

  • calculating mean values for event, preevent and post event years.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double fyear str10 cusip float(built major) double(aqc capx)
    1989 "666499207" . .       0   3.402
    1989 "398629204" . .    .644   3.174
    1989 "385006101" . .       0  12.014
    1989 "090915109" . .   9.173   5.087
    1989 "449842103" . .       0  18.196
    1989 "244878203" . .       0    15.4
    1989 "170032809" . .       . 111.928
    1989 "914272109" . .       0    .001
    1989 "256603101" . .  14.364 303.906
    1989 "016230104" . .       0   9.719
    1989 "628452104" . .       0     .55
    1989 "570279109" . .       0    .136
    1989 "871371100" . .       .   2.702
    1989 "723686101" . .       0  95.952
    1989 "755078102" . .       0  13.446
    1989 "129598108" . .    -.27   2.129
    1989 "209885102" . .       0       0
    1989 "233236108" . .       0    .753
    1989 "028689107" . .       0   1.568
    1989 "879080109" . .       0    .904
    1990 "755078102" . .       0  14.601
    1990 "170032809" 1 .       . 282.475
    1990 "244878203" . .    30.6    15.7
    1990 "879080109" . 1       0   1.371
    1990 "570279109" . .       0    .058
    1990 "016230104" . .       0  11.649
    1990 "628452104" . .       0   2.546
    1990 "209885102" . .       0       0
    1990 "871371100" . .       0   8.023
    1990 "090915109" . .       0       .
    1990 "723686101" . .   6.042  73.667
    1990 "398629204" . .       0   3.925
    1990 "385006101" . .       0  10.671
    1990 "233236108" . .       0    .621
    1990 "129598108" . .    .334   2.604
    1990 "256603101" . .  18.564 246.527
    1990 "449842103" . .       0  21.728
    1990 "568247100" . .       0   1.164
    1990 "666499207" . .       0   6.978
    1990 "028689107" . 1       0    1.51
    1991 "233236108" . .       0    .376
    1991 "568247100" . .       0    .492
    1991 "570279109" 1 .       0    .001
    1991 "15745J205" . 1       0   1.482
    1991 "244878203" . .       0    15.5
    1991 "090915109" . .       0       .
    1991 "666499207" . .       0   3.722
    1991 "016230104" . .       0   12.93
    1991 "170032809" . .       .  355.16
    1991 "755078102" . .       0  13.725
    1991 "209885102" . .       0       0
    1991 "879080109" . .       0    .902
    1991 "449842103" . .       0   17.89
    1991 "129598108" . .    .315   1.464
    1991 "723686101" . .  26.052  51.229
    1991 "256603101" . .       0  325.16
    1991 "628452104" . .   10.89   5.804
    1991 "398629204" . 1      .2   3.775
    1991 "871371100" . .  14.596   4.185
    1992 "879080109" . .       0   1.285
    1992 "129598108" . .       0   1.461
    1992 "568247100" . .       0   1.792
    1992 "449842103" . .       0  38.548
    1992 "628452104" . .  -2.111    2.09
    1992 "233236108" . .       0   1.039
    1992 "247357106" . .       0     4.5
    1992 "755078102" . .       0   14.02
    1992 "666499207" . .   2.988   6.461
    1992 "170032809" . .       .  409.77
    1992 "256603101" 1 .  14.342 204.923
    1992 "398629204" . .       0   5.184
    1992 "871371100" . 1   3.804   7.751
    1992 "209885102" . .       0       0
    1992 "016230104" . .       0   7.993
    1992 "723686101" . .   2.763  74.853
    1992 "15745J205" . .       0   3.949
    1992 "244878203" . .       0    21.3
    1993 "233236108" . .     .15    .331
    1993 "170032809" . .       . 196.554
    1993 "244878203" . .       0    15.9
    1993 "209885102" . .       0   2.838
    1993 "247357106" . .       0   2.342
    1993 "449842103" . .       0  53.741
    1993 "871371100" . .       0    3.56
    1993 "879080109" . .       0   1.441
    1993 "628452104" . .     7.4   5.765
    1993 "129598108" . .   2.322   4.607
    1993 "755078102" . 1       0  13.353
    1993 "723686101" 1 .       0  99.926
    1993 "398629204" . .       0    2.98
    1993 "090915109" . .   -.309       .
    1993 "15745J205" . .       0   4.862
    1993 "016230104" . .       0   7.626
    1993 "256603101" . . 107.996 218.659
    1993 "G36738105" . .       0    14.9
    1993 "740577101" . .       0     .96
    1993 "666499207" . .       0  10.587
    1993 "568247100" . 1  50.494   4.742
    1994 "398629204" . .       0   7.165
    1994 "209885102" . .       0       0
    end
    I need to find mean values of (capx and aqc) for event year where built=1 and also pre-event and post event years(pre-event is a year before where built=1 for a company(cusip) same way post-event is year after the event where built=1 for a company(cusip)) based on company(cusip).



  • #2
    Can anyone here please help me?

    Comment


    • #3
      Many of the most active members of Statalist are in locations where today is not a workday, and thus they are not looking at Stata or Statalist. And your second post was at 9:25 in the morning in the easternmost part of the United States, and three hours earlier in the westernmost part, so even those in the Americas inclined to look at Stata have perhaps not yet risen at the time of your second post. And those who saw it later may have

      The following code may start you in a useful direction by identifying pre and post years.
      Code:
      sort cusip fyear
      by cusip (fyear): egen hasbuilt = max(built)
      drop if hasbuilt!=1
      drop hasbuilt
      by cusip (fyear): generate pre = built[_n+1]==1
      by cusip (fyear): generate post = built[_n-1]==1
      When applied to your sample data the result is
      Code:
      . list, sepby(cusip)
      
           +--------------------------------------------------------------------+
           | fyear       cusip   built   major       aqc      capx   pre   post |
           |--------------------------------------------------------------------|
        1. |  1989   170032809       .       .         .   111.928     1      0 |
        2. |  1990   170032809       1       .         .   282.475     0      0 |
        3. |  1991   170032809       .       .         .    355.16     0      1 |
        4. |  1992   170032809       .       .         .    409.77     0      0 |
        5. |  1993   170032809       .       .         .   196.554     0      0 |
           |--------------------------------------------------------------------|
        6. |  1989   256603101       .       .    14.364   303.906     0      0 |
        7. |  1990   256603101       .       .    18.564   246.527     0      0 |
        8. |  1991   256603101       .       .         0    325.16     1      0 |
        9. |  1992   256603101       1       .    14.342   204.923     0      0 |
       10. |  1993   256603101       .       .   107.996   218.659     0      1 |
           |--------------------------------------------------------------------|
       11. |  1989   570279109       .       .         0      .136     0      0 |
       12. |  1990   570279109       .       .         0      .058     1      0 |
       13. |  1991   570279109       1       .         0      .001     0      0 |
           |--------------------------------------------------------------------|
       14. |  1989   723686101       .       .         0    95.952     0      0 |
       15. |  1990   723686101       .       .     6.042    73.667     0      0 |
       16. |  1991   723686101       .       .    26.052    51.229     0      0 |
       17. |  1992   723686101       .       .     2.763    74.853     1      0 |
       18. |  1993   723686101       1       .         0    99.926     0      0 |
           +--------------------------------------------------------------------+

      Comment


      • #4
        Thank you sir

        Comment

        Working...
        X