Announcement

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

  • count in groups

    Hi all,
    I am struggling right now with following task (attached the data): I want to find the year in which most transitions happen.
    So I created the transition year variable:
    egen company_id = group(gvkey)
    drop gvkey

    //generate Transition year
    gen transition_year = year + trans_window
    //count transitions per year
    No I need to find out in which year (transition_year) most transitions happened.
    I first wanted to group(company_id transition year) as I want to count the number of different companies, all having a transition in this particular year

    But I don't know how to continue? Does anyone know how I will find out this information?

    Thanks!!!
    Pauline
    Attached Files

  • #2
    What variable is measuring transitions? Are you looking for a count of unique values of transition_year (which has a lot of duplication)?

    Spit-balling.

    Code:
    preserve
    
    collapse year, by(company_id transition_year)
    
    tab transition_year
    
    transition_ 
    year       Freq.     Percent        Cum.
    
    1975           4        0.21        0.21
    1976           4        0.21        0.42
    1977          10        0.53        0.95
    1978          10        0.53        1.47
    1979          16        0.84        2.31
    1980          23        1.21        3.52
    1981          23        1.21        4.73
    1982          30        1.58        6.31
    1983          34        1.79        8.09
    1984          58        3.05       11.14
    1985          64        3.36       14.50
    1986          68        3.57       18.08
    1987          84        4.41       22.49
    1988          98        5.15       27.64
    1989         109        5.73       33.37
    1990          91        4.78       38.15
    1991         110        5.78       43.93
    1992         115        6.04       49.97
    1993         130        6.83       56.81
    1994         100        5.25       62.06
    1995         109        5.73       67.79
    1996          97        5.10       72.88
    1997         106        5.57       78.46
    1998          70        3.68       82.13
    1999          82        4.31       86.44
    2000          62        3.26       89.70
    2001          77        4.05       93.75
    2002          38        2.00       95.74
    2003          40        2.10       97.85
    2004          19        1.00       98.84
    2005          18        0.95       99.79
    2006           4        0.21      100.00
    
    Total       1,903      100.00
    
    restore
    Of course, there are other ways to get to the same thing.
    Last edited by George Ford; 20 Nov 2022, 07:20.

    Comment


    • #3
      Pauline Mueller please don't attach Stata datafiles, people are unlikely to want to open a file from an unknown source. Instead please include a well-chosen extract of your data using the dataex command, as recommended in the Statalist FAQ (see esp. section 12). Also, as requested in #2, it would help to understand how to count "transitions" -- a better description of this, and perhaps some example results for your data extract, would go a long way in helping people help you.

      Comment

      Working...
      X