Announcement

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

  • Keeping observation after it passes a certain threshold

    Hello everyone I hope you're doing all good.

    As part my study, I am aggregating assets of "divisions" (fundno) of "companies" (portno) to keep only these companies that have at least 10 mln assets, when all divisions are summarized in a month t. If a company does not have a minimum of 10 mln assets it is dropped.
    Yet sometimes, the company achieves the 10 mln, but later it might drop below the level. Thus, once it has reached 10 mln, even if in some future months the assets are below 10mln, I would like to keep it in my sample to make it less volatile and to avoid selection bias.

    May I kindly ask you for some help on that case?

    So far I did:
    -egen totalmtna=total(mtna), by (crsp_portno mofd)- and then
    -drop if totalmtna<10-


    Sample
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(crsp_fundno crsp_portno) float mofd double mtna
    4278 1000001 566                 .3
    4276 1000001 534                7.9
    4279 1000001 577               22.8
    4278 1000001 570                1.4
    4273 1000001 526              393.9
    4278 1000001 597                5.6
    4275 1000001 411              1.385
    4276 1000001 561               24.5
    4275 1000001 416               1.22
    4275 1000001 560               26.9
    4275 1000001 468              224.9
    4273 1000001 527                395
    4276 1000001 568               27.6
    4273 1000001 438              272.7
    4278 1000001 586                2.4
    4273 1000001 410 193.00300000000001
    4276 1000001 567               27.4
    4276 1000001 578               21.9
    4275 1000001 565               27.5
    4276 1000001 542                8.7
    4273 1000001 523              372.3
    4276 1000001 492                110
    4279 1000001 548               20.3
    4278 1000001 604                  7
    4275 1000001 465              197.5
    4276 1000001 499               85.4
    4275 1000001 406              1.428
    4276 1000001 601               22.9
    4279 1000001 600                173
    4276 1000001 491              110.7
    4273 1000001 525              384.9
    4277 1000001 550                 .1
    4279 1000001 545               19.4
    4273 1000001 402 236.00099999999998
    4275 1000001 437             20.777
    4277 1000001 548                 .1
    4275 1000001 492                106
    4275 1000001 537               35.2
    4273 1000001 413             172.37
    4275 1000001 472              196.2
    4275 1000001 464              182.6
    4275 1000001 443             39.784
    4279 1000001 552               23.2
    4279 1000001 570               42.5
    4276 1000001 513                8.7
    4278 1000001 565                 .7
    4277 1000001 594                  3
    4276 1000001 559               23.2
    4275 1000001 522               39.4
    4275 1000001 505               63.7
    4275 1000001 519               34.4
    4275 1000001 592               12.3
    4276 1000001 443              2.327
    4279 1000001 549               19.7
    4273 1000001 444            489.257
    4276 1000001 597               20.3
    4277 1000001 553                 .1
    4273 1000001 427            162.245
    4275 1000001 581               20.4
    4273 1000001 593 150.70000000000002
    4275 1000001 523               41.6
    4275 1000001 490              100.9
    4275 1000001 474              191.9
    4276 1000001 521                8.6
    4273 1000001 540              348.7
    4278 1000001 551                 .1
    4277 1000001 556                 .1
    4276 1000001 462            208.507
    4273 1000001 389            280.808
    4273 1000001 423 143.93099999999998
    4273 1000001 462 1335.3780000000002
    4273 1000001 598              158.4
    4276 1000001 501               74.8
    4276 1000001 457            187.313
    4275 1000001 425              1.797
    4275 1000001 507               63.3
    4275 1000001 471              195.3
    4277 1000001 544                 .1
    4275 1000001 452            145.464
    4279 1000001 598                167
    4275 1000001 405               1.23
    4275 1000001 429              2.301
    4275 1000001 446             66.738
    4275 1000001 584               17.5
    4275 1000001 413              1.365
    4279 1000001 604              196.2
    4275 1000001 598               13.4
    4277 1000001 567                1.1
    4275 1000001 403               .095
    4278 1000001 576                  2
    4276 1000001 484              116.7
    4279 1000001 603              213.6
    4278 1000001 548                 .1
    4275 1000001 481              169.4
    4277 1000001 597                3.6
    4276 1000001 512                8.9
    4278 1000001 564                 .7
    4276 1000001 580                 28
    4273 1000001 568              298.1
    4276 1000001 498               93.9
    end
    Forgive me if my question seems trivial for you.

    Best,
    Rafal

  • #2
    Perhaps this will start you in a useful direction.
    Code:
    sort crsp_portno mofd
    by crsp_portno mofd: egen totalmtna = total(mtna)
    generate gteq10=totalmtna>10
    by crsp_portno (mofd): replace gteq10 = gteq10[_n-1] if gteq10==0
    drop if gteq10==0

    Comment


    • #3
      Thank you very much William! This is very useful. I do appreciate your help. The code created missing values, and I think that the last line should be -drop if missing(gteq10)-

      Best regards,
      RafaƂ

      Comment


      • #4
        While what you suggest will work, it would be better to correct my error by changing the replace command to
        Code:
        by crsp_portno (mofd): replace gteq10 = gteq10[_n-1] if gteq10==0 & _n>1
        and the drop command will work as written.

        Comment

        Working...
        X