Announcement

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

  • Code for companies overlap in a market

    Hi,
    I'm with the data like follows,
    Market Company Time
    1 A 2009
    1 B 2009
    1 C 2009
    2 B 2009
    2 C 2009
    2 D 2009
    2 E 2009
    3 A 2009
    3 D 2009
    3 E 2009
    3 F 2009
    Market Company Time
    1 A 2010
    1 B 2010
    1 C 2010
    1 D 2010
    2 B 2010
    2 C 2010
    2 D 2010
    2 E 2010
    3 A 2010
    3 D 2010
    3 E 2010
    3 F 2010
    1. I was wondering how can I figure out whether both Company B and C are present in a Market or not (may be by generating a dummy).
    2. And how to count the Companies show in each Market in different year?

    Appreciate any help.
    Last edited by Alex Dong; 29 Apr 2022, 16:25.

  • #2
    Code:
    bysort Market Time (Company): egen one = max(Company=="B" & Company[_n+1]=="C")
    bysort Market Time (Company): gen two = _N

    Comment


    • #3
      Originally posted by Øyvind Snilsberg View Post
      Code:
      bysort Market Time (Company): egen one = max(Company=="B" & Company[_n+1]=="C")
      bysort Market Time (Company): gen two = _N
      Thank you Oyvind for your help. I still have a question which is my company B and C is not in ordered.

      Comment


      • #4
        A question very similar to this is asked and answered at https://www.statalist.org/forums/for...te-overlapping, and I believe the answer there, with minimal adaptation, applies here as well.

        Comment

        Working...
        X