Announcement

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

  • How to combine data for panel data?

    Hi, I have 5/6 years of data from several companies from different industries. How do I combine it for panel data analysis using Stata?
    Est./Event Window Date Market Price Rmt Stock Price R %Stock %Market Bid Price Ask Price PS
    61 1-Aug-19 1639.06706 0.00257 1.05 0.0000 0.0000 0.0026 1.03 1.05 1.10
    60 31-Jul-19 1634.86517 -0.00477 1.05 (0.0189) (0.0187) (0.0048) 1.04 1.05 1.10
    59 29-Jul-19 1642.68923 -0.00320 1.07 (0.0093) (0.0093) (0.0032) 1.05 1.07 1.14
    58 26-Jul-19 1647.96245 -0.00522 1.08 0.0000 0.0000 (0.0052) 1.07 1.08 1.16
    57 25-Jul-19 1656.58391 0.00252 1.08 0.0282 0.0286 0.0025 1.08 1.09 1.18
    56 24-Jul-19 1652.41200 -0.00197 1.05 0.0096 0.0096 (0.0020) 1.04 1.05 1.10
    55 23-Jul-19 1655.66925 0.00016 1.04 (0.0096) (0.0095) 0.0002 1.04 1.05 1.10
    54 22-Jul-19 1655.39698 -0.00169 1.05 0.0000 0.0000 (0.0017) 1.04 1.05 1.10
    53 19-Jul-19 1658.18952 0.00560 1.05 (0.0095) (0.0094) 0.0056 1.04 1.05 1.10
    52 18-Jul-19 1648.92563 -0.00521 1.06 0.0000 0.0000 (0.0052) 1.05 1.06 1.12
    51 17-Jul-19 1657.53114 -0.00686 1.06 0.0190 0.0192 (0.0068) 1.05 1.06 1.12
    50 16-Jul-19 1668.93918 -0.00205 1.04 (0.0096) (0.0095) (0.0021) 1.03 1.04 1.08
    49 15-Jul-19 1672.36831 0.00175 1.05 0.0000 0.0000 0.0017 1.04 1.05 1.10
    48 12-Jul-19 1669.44883 -0.00586 1.05 (0.0189) (0.0187) (0.0058) 1.05 1.06 1.12
    47 11-Jul-19 1679.25721 0.00017 1.07 (0.0546) (0.0531) 0.0002 1.06 1.07 1.14
    46 10-Jul-19 1678.97279 -0.00232 1.13 0.0089 0.0089 (0.0023) 1.12 1.13 1.26
    45 9-Jul-19 1682.87056 0.00311 1.12 0.0000 0.0000 0.0031 1.11 1.12 1.24
    44 8-Jul-19 1677.63755 -0.00291 1.12 (0.0089) (0.0088) (0.0029) 1.11 1.12 1.24
    43 5-Jul-19 1682.52855 -0.00294 1.13 0.0089 0.0089 (0.0029) 1.11 1.13 1.26
    42 4-Jul-19 1687.48177 -0.00152 1.12 0.0090 0.0090 (0.0015) 1.12 1.13 1.26
    41 3-Jul-19 1690.04643 -0.00056 1.11 0.0000 0.0000 (0.0006) 1.11 1.12 1.24
    40 2-Jul-19 1690.99623 0.00437 1.11 0.0274 0.0278 0.0044 1.10 1.11 1.22
    39 1-Jul-19 1683.62424 0.00685 1.08 (0.0092) (0.0092) 0.0069 1.08 1.09 1.18
    38 28-Jun-19 1672.12849 -0.00034 1.09 0.0092 0.0093 (0.0003) 1.08 1.09 1.18
    37 27-Jun-19 1672.69907 -0.00107 1.08 0.0093 0.0093 (0.0011) 1.07 1.08 1.16
    36 26-Jun-19 1674.48565 -0.00127 1.07 (0.0093) (0.0093) (0.0013) 1.06 1.08 1.16
    35 25-Jun-19 1676.61245 0.00029 1.08 (0.0092) (0.0092) 0.0003 1.07 1.08 1.16
    34 24-Jun-19 1676.13394 -0.00363 1.09 (0.0091) (0.0091) (0.0036) 1.08 1.09 1.18
    33 21-Jun-19 1682.22563 0.00404 1.10 0.0000 0.0000 0.0041 1.09 1.10 1.20
    32 20-Jun-19 1675.43498 0.00532 1.10 0.0277 0.0280 0.0053 1.09 1.10 1.20
    31 19-Jun-19 1666.53766 0.00830 1.07 (0.0093) (0.0093) 0.0083 1.07 1.08 1.16
    30 18-Jun-19 1652.75957 0.00872 1.08 0.0000 0.0000 0.0088 1.07 1.08 1.16
    29 17-Jun-19 1638.40345 -0.00014 1.08 (0.0092) (0.0092) (0.0001) 1.07 1.08 1.16
    28 14-Jun-19 1638.62512 -0.00312 1.09 (0.0182) (0.0180) (0.0031) 1.08 1.09 1.18
    27 13-Jun-19 1643.74328 -0.00424 1.11 0.0274 0.0278 (0.0042) 1.10 1.11 1.22
    26 12-Jun-19 1650.73544 -0.00028 1.08 0.0187 0.0189 (0.0003) 1.07 1.08 1.16
    25 11-Jun-19 1651.19732 -0.00259 1.06 0.0000 0.0000 (0.0026) 1.06 1.07 1.14
    24 10-Jun-19 1655.47437 0.00372 1.06 0.0095 0.0095 0.0037 1.06 1.07 1.14
    23 7-Jun-19 1649.33258 0.00318 1.05 0.0192 0.0194 0.0032 1.04 1.05 1.10
    22 4-Jun-19 1644.09344 -0.00680 1.03 (0.0192) (0.0190) (0.0068) 1.03 1.05 1.10
    21 3-Jun-19 1655.30991 0.00275 1.05 0.0000 0.0000 0.0028 1.04 1.05 1.10
    20 31-May-19 1650.76107 0.00868 1.05 (0.0189) (0.0187) 0.0087 1.05 1.07 1.14
    19 30-May-19 1636.50258 0.00787 1.07 0.0094 0.0094 0.0079 1.07 1.08 1.16
    18 29-May-19 1623.66821 0.00562 1.06 0.0287 0.0291 0.0056 1.06 1.07 1.14
    17 28-May-19 1614.56644 0.00822 1.03 (0.0097) (0.0096) 0.0083 1.02 1.05 1.10
    16 27-May-19 1601.35209 0.00189 1.04 0.0097 0.0097 0.0019 1.03 1.04 1.08
    15 24-May-19 1598.32375 -0.00221 1.03 0.0000 0.0000 (0.0022) 1.02 1.03 1.06
    14 23-May-19 1601.86685 -0.00117 1.03 0.0000 0.0000 (0.0012) 1.01 1.03 1.06
    13 21-May-19 1603.73789 -0.00101 1.03 (0.0097) (0.0096) (0.0010) 1.03 1.05 1.10
    12 17-May-19 1605.36065 0.00385 1.04 (0.0190) (0.0189) 0.0039 1.04 1.05 1.10
    11 16-May-19 1599.18815 -0.00762 1.06 (0.0094) (0.0093) (0.0076) 1.05 1.06 1.12
    10 15-May-19 1611.42788 0.00762 1.07 0.0094 0.0094 0.0077 1.05 1.07 1.14
    9 14-May-19 1599.19021 -0.00119 1.06 0.0190 0.0192 (0.0012) 1.05 1.06 1.12
    8 13-May-19 1601.09213 -0.00572 1.04 (0.0377) (0.0370) (0.0057) 1.03 1.04 1.08
    7 10-May-19 1610.27282 -0.00512 1.08 (0.0183) (0.0182) (0.0051) 1.07 1.09 1.18
    6 9-May-19 1618.53186 -0.00923 1.10 0.0183 0.0185 (0.0092) 1.09 1.10 1.20
    5 8-May-19 1633.54799 -0.00356 1.08 (0.0183) (0.0182) (0.0036) 1.08 1.09 1.18
    4 7-May-19 1639.37188 0.00402 1.10 0.0183 0.0185 0.0040 1.08 1.10 1.20
    3 6-May-19 1632.80024 -0.00275 1.08 (0.0274) (0.0270) (0.0028) 1.07 1.08 1.16
    2 3-May-19 1637.3033 0.00310 1.11 0.0000 0.0000 0.0031 1.10 1.11 1.22
    1 2-May-19 1632.23886 -0.00614 1.11 (0.0090) (0.0089) (0.0061) 1.10 1.11 1.22
    0 30-Apr-19 1642.28843 0.00298 1.12 (0.0177) (0.0175) 0.0030 1.12 1.13 1.26
    -1 29-Apr-19 1637.40128 -0.00060 1.14 0.0088 0.0088 (0.0006) 1.12 1.14 1.28
    -2 26-Apr-19 1638.37995 0.00165 1.13 0.0000 0.0000 0.0017 1.12 1.13 1.26
    -3 25-Apr-19 1635.67895 -0.00142 1.13 0.0089 0.0089 (0.0014) 1.12 1.13 1.26
    -4 24-Apr-19 1638.00664 0.00647 1.12 0.0090 0.0090 0.0065 1.11 1.12 1.24
    -5 23-Apr-19 1627.4432 0.00332 1.11 (0.0179) (0.0177) 0.0033 1.11 1.13 1.26
    -6 22-Apr-19 1622.05638 -0.00001 1.13 0.0360 0.0367 (0.0000) 1.13 1.14 1.28
    -7 19-Apr-19 1622.06854 0.00144 1.09 0.0000 0.0000 0.0014 1.09 1.10 1.20
    -8 18-Apr-19 1619.73477 -0.00072 1.09 0.0279 0.0283 (0.0007) 1.08 1.09 1.18
    -9 17-Apr-19 1620.90464 -0.00526 1.06 (0.0279) (0.0275) (0.0052) 1.06 1.07 1.14
    -10 16-Apr-19 1629.4572 -0.00115 1.09 0.0000 0.0000 (0.0011) 1.09 1.10 1.20
    -11 15-Apr-19 1631.33047 0.00071 1.09 (0.0272) (0.0268) 0.0007 1.09 1.10 1.20
    -12 12-Apr-19 1630.16701 0.00365 1.12 0.0000 0.0000 0.0037 1.11 1.12 1.24
    -13 11-Apr-19 1624.23053 -0.00933 1.12 (0.0264) (0.0261) (0.0093) 1.12 1.13 1.26
    -14 10-Apr-19 1639.46133 -0.00151 1.15 0.0175 0.0177 (0.0015) 1.13 1.15 1.30
    -15 9-Apr-19 1641.93654 -0.00147 1.13 (0.0088) (0.0088) (0.0015) 1.13 1.14 1.28
    -16 8-Apr-19 1644.35271 0.00155 1.14 0.0267 0.0270 0.0015 1.13 1.14 1.28
    -17 5-Apr-19 1641.80833 -0.00199 1.11 0.0090 0.0091 (0.0020) 1.09 1.11 1.22
    -18 4-Apr-19 1645.07083 0.00113 1.10 (0.0180) (0.0179) 0.0011 1.10 1.12 1.24
    -19 3-Apr-19 1643.21004 0.00633 1.12 0.0000 0.0000 0.0064 1.11 1.12 1.24
    -20 2-Apr-19 1632.83494 0.00256 1.12 (0.0089) (0.0088) 0.0026 1.12 1.13 1.26
    -21 1-Apr-19 1628.66183 -0.00915 1.13 0.0000 0.0000 (0.0091) 1.12 1.13 1.26
    -22 29-Mar-19 1643.62533 0.00140 1.13 0.0089 0.0089 0.0014 1.12 1.13 1.26
    -23 28-Mar-19 1641.32506 -0.00085 1.12 0.0364 0.0370 (0.0009) 1.12 1.13 1.26
    -24 27-Mar-19 1642.72735 -0.00438 1.08 (0.0364) (0.0357) (0.0044) 1.08 1.11 1.22
    -25 26-Mar-19 1649.94165 0.00048 1.12 0.0272 0.0275 0.0005 1.11 1.12 1.24
    -26 25-Mar-19 1649.14617 -0.01056 1.09 (0.0708) (0.0684) (0.0105) 1.09 1.10 1.20
    -27 22-Mar-19 1666.65507 0.00180 1.17 0.0000 0.0000 0.0018 1.16 1.17 1.34
    -28 21-Mar-19 1663.65592 -0.01228 1.17 0.0172 0.0174 (0.0122) 1.17 1.18 1.36
    -29 20-Mar-19 1684.21376 -0.00205 1.15 0.0175 0.0177 (0.0021) 1.14 1.15 1.30
    -30 19-Mar-19 1687.67519 -0.00193 1.13 (0.0348) (0.0342) (0.0019) 1.13 1.14 1.28
    -31 18-Mar-19 1690.94325 0.00617 1.17 0.1178 0.1250 0.0062 1.17 1.18 1.36
    -32 15-Mar-19 1680.53664 0.00359 1.04 0.0000 0.0000 0.0036 1.04 1.05 1.10
    -33 14-Mar-19 1674.51827 -0.00222 1.04 0.0000 0.0000 (0.0022) 1.04 1.05 1.10
    -34 13-Mar-19 1678.23564 0.00415 1.04 0.0097 0.0097 0.0042 1.03 1.05 1.10
    -35 12-Mar-19 1671.28411 0.00399 1.03 (0.0192) (0.0190) 0.0040 1.02 1.03 1.06
    -36 11-Mar-19 1664.62725 -0.00914 1.05 0.0488 0.0500 (0.0091) 1.03 1.05 1.10
    -37 8-Mar-19 1679.90413 -0.00418 1.00 0.0151 0.0152 (0.0042) 1.00 1.01 1.02
    -38 7-Mar-19 1686.94885 0.00007 0.99 0.0051 0.0051 0.0001 0.99 0.99 0.98
    -39 6-Mar-19 1686.82266 0.00071 0.98 0.0051 0.0051 0.0007 0.98 0.98 0.96
    -40 5-Mar-19 1685.62289 -0.00495 0.98 (0.0153) (0.0152) (0.0049) 0.97 0.98 0.96
    -41 4-Mar-19 1693.9889 -0.00399 0.99 0.0000 0.0000 (0.0040) 0.98 0.99 0.98
    -42 1-Mar-19 1700.75854 -0.00409 0.99 0.0000 0.0000 (0.0041) 0.99 0.99 0.98
    -43 28-Feb-19 1707.72671 -0.00335 0.99 (0.0101) (0.0100) (0.0033) 0.99 1.00 0.99
    -44 27-Feb-19 1713.451 -0.00323 1.00 0.0202 0.0204 (0.0032) 1.00 1.01 1.02
    -45 26-Feb-19 1718.99847 -0.00324 0.98 (0.0051) (0.0051) (0.0032) 0.98 0.98 0.96
    -46 25-Feb-19 1724.58449 0.00184 0.99 0.0051 0.0051 0.0018 0.98 0.99 0.97
    -47 22-Feb-19 1721.42226 -0.00537 0.98 (0.0102) (0.0101) (0.0054) 0.98 0.99 0.97
    -48 21-Feb-19 1730.68382 0.00260 0.99 0.0051 0.0051 0.0026 0.99 0.99 0.98
    -49 20-Feb-19 1726.18435 0.01143 0.99 0.0051 0.0051 0.0115 0.98 1.00 0.99
    -50 19-Feb-19 1706.56189 0.00813 0.98 (0.0152) (0.0151) 0.0082 0.98 0.98 0.96
    -51 18-Feb-19 1692.7449 0.00232 1.00 0.0463 0.0474 0.0023 0.99 1.00 0.99
    -52 15-Feb-19 1688.82537 -0.00014 0.95 0.0106 0.0106 (0.0001) 0.95 0.95 0.90
    -53 14-Feb-19 1689.0609 0.00223 0.94 0.0053 0.0053 0.0022 0.94 0.94 0.88
    -54 13-Feb-19 1685.29877 -0.00125 0.94 0.0162 0.0163 (0.0012) 0.93 0.94 0.87
    -55 12-Feb-19 1687.40676 -0.00068 0.92 0.0054 0.0055 (0.0007) 0.92 0.93 0.86
    -56 11-Feb-19 1688.5598 0.00121 0.92 0.0055 0.0055 0.0012 0.91 0.92 0.83
    -57 8-Feb-19 1686.5228 -0.00407 0.91 0.0000 0.0000 (0.0041) 0.91 0.91 0.82
    -58 7-Feb-19 1693.39375 0.00580 0.91 0.0166 0.0168 0.0058 0.90 0.91 0.82
    -59 4-Feb-19 1683.60762 0.00004 0.90 0.0169 0.0170 0.0000 0.89 0.90 0.79
    -60 31-Jan-19 1683.5336 -0.00034 0.88 0.0057 0.0057 (0.0003) 0.88 0.88 0.76



  • #2
    Kathy:
    welcome to this forum.
    The first step is to -xtset- your data (assuming that -company- is your -panelid-):
    Code:
    xtset companyid timevar
    If you have repeated values for the same date for the same -idcompany-, you can -xtset- with -companyid- only, being aware that this fix will not allow you to use time-series related functions such as lags and leads.
    That said, if your regressand is continuus, you can go -xtreg,fe- or -xtreg,re-: if you use defauls standard errors, you can compare the two specifications via -hausman- test. whereas is shous switch to the community-contributed module -xtoverid if you invoke non-default standard errors.
    Eventually, as far as the categordical variable -industry- is concerned, if companies do not change industry during the span of time the panel dataset stretches over and you go -fe-, as expected the -fe- estimator will wipe out the -industry- variable due to its time-invariance.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      You need a company identifier (not shown) and a time identifier (date is yours, I suppose). If they are in separate files, then you can use append. Dates would need to be the same for all. Alternately, if you are more interested in the event date interval, you can use that (not sure how state would handle the negative values; haven't run into that). If it's a problem, create a new time variable (g t = _n in individual files or bys companyid: g t = _n if already merged) for each if the event date intervals are all the same.

      Code:
      clear
      set obs 0
      append using company1
      append using company2
      append using company3


      Comment

      Working...
      X