Announcement

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

  • How do I create a constant sample of firms

    Hi, I would need some help with the following problem please, I'm a new STATA user:

    I have a list of firms from COMPUSTAT from 1950 to 1998. I need to hold the number of firms constant between 1968 and 1998 (meaning that I need to keep the firms that existed for all those 31 years). Also, I have to keep those firms between 1950 and 1967, that still existed in 1998. I'm posting a photo of the sample I need to create- firms from 1668 and 1998 are steady 896, but firms before that period are those that existed both in that year and in 1998.
    I know how to create a constant sample between 1968 and 1998- that is I need to use:
    keep if fyear>=1968
    keep if fyear<=1998
    bys conm: gen nyear=[_N]
    keep if nyear==31
    But I don't know how to create the additional period of 1950- 1967 in the same file.
    Attached Files
    Last edited by Mark Leve; 22 Feb 2020, 07:09.

  • #2
    Cross-posted at https://www.reddit.com/r/stata/comme...mple_of_firms/

    Please note our policy on cross-posting, which is that you are asked to tell us about it. https://www.statalist.org/forums/help#crossposting

    The folks at Reddit must shift for themselves, but I have never seen complaints if someone is explicit about cross-posting.

    That said I am not completely clear on what you want here, an impression which if shared would cut down on answers here. But the first step

    Code:
    keep if fyear>=1968
    immediately removes all information on what happened earlier

    A criterion for existing in every year from 1950 to 1967 is that

    Code:
    egen earlier = total(inlist(fyear, 1950, 1967)), by(comm)
    is returned as 18. A criterion for existing in 1998 is that

    Code:
    egen in1998 = total(fyear == 1998), by(comm)
    is returned as 1. That may help you make progress. A survey of some of the tricks in this territory is given at https://www.stata-journal.com/articl...article=dm0055

    See also https://www.statalist.org/forums/help#spelling

    Comment

    Working...
    X