Announcement

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

  • #16
    You are correct that A. Douglas Rao never manages firm B by himself. And there is no such listing in the output. He does have a period where he manages firm C by himself, and that does appear in the output. Here's the output I get with code from #11 applied to the data example in #12:

    Code:
        firm_name         manager_name   datebegin     dateend  
                A       Jon E. Quigley   29jul2013   29jul2014  
                B   Scott W. Schoelzel   21may2003   01jan2008  
                B            Ron Sachs   01may2008   28sep2012  
                C   Scott W. Schoelzel   21may2003   01jan2008  
                C            Ron Sachs   01may2008   04jun2013  
                C       A. Douglas Rao   04jun2013   01sep2013
    (Well, actually the code in #11 has to be modified to rename begin and end as datebegin and dateend in order to run. But what you see here is the output from otherwise unchanged code from #11.)

    Comment


    • #17
      If the cumulative range of time for each firm is not too large (over 7-8000 years), below code should also be working. For the given example or small data, you could directly use the program's content without using -runby-.
      Code:
      capture program drop each_firm
      program define each_firm
          gen long obs = _n
          expand 1 + end - begin
      
          bys obs: gen date = begin +_n-1
          bys firm_name date: keep if _N==1
      
          bys firm_name manager_name (date): gen tag = sum(date != date[_n-1]+1)
      
          collapse (min) begin_S = date (max) end_S = date, by(firm_name manager_name tag)
          drop tag
      end
      
      runby each_firm, by(firm_name)
      format %td begin_S end_S

      Comment


      • #18
        Clyde Schechter : Thank you very much. How silly I am. I got it now. The code run smoothly and no issue so far. Thank you again.
        Romalpa Akzo: Thank you, I will run your code on my original data to see how it works. It's very helpful to see different solutions for the question.

        Kind regards;
        Mia

        Comment


        • #19
          It should be noted that the code in #17 follows the strict level of date, therefore, its output would be silghly different from Professor Clyde's code in #11.

          For example, the begin_Single of Jon E. Quigley (firm A) is 30 July 2013 instead of 29 July 2013. Similarly, the end_Single of Scott W. Schoelze (firm B) is 31 Dec 2007 instead of 01 Jan 2008.

          Comment

          Working...
          X