Announcement

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

  • How can I list observations from panel without repeating?

    Dear Community,

    I have panel data on companies. I wanna have a list of the companies (var company) for which an indicator( var ind) is greater than 50. Since I have a panel I have reapeted company names when I type:
    list company if ind>50

    I don't wanna know how many times a given company had an indicator greater than 50. I just wanna know for which companies it occured that an indicator was greater than 50.

  • #2
    Code:
    levelsof company if x > 50

    Comment


    • #3
      Thank you for your answer. Since I have many companies it is hard to read the result from levelsof. Is there any other way? So that e.g. I would have a list of firms?

      Comment


      • #4
        Code:
        egen tag = tag(company)
        list company if tag & ind>50
        Code:
        tab company if ind>50

        Comment


        • #5
          Thank you so much for your answer! It helped me a lot. Is there a way to count the number of companies? I typed:
          count company if tag & ind>100

          However, I got an error message: varlist not allowed

          Comment


          • #6
            Code:
            count if tag & ind>100

            Comment


            • #7
              There is a subtlety here. Suppose for a given company ind varies from 42 to 666 but the tagged observation has value 42. That might be a company you want to know about.

              I imagine the question to have two interpretations for a given company:

              is any value
              ind > 50?

              and

              are all values
              ind > 50?

              If the value of
              ind is constant for a company, the answers are the same, and that could be true otherwise. But as first mentioned, the two rules won't always have the same answers.

              The ambiguity shows, once again, the importance of giving us a detailed example showing your rules.

              The principles here are discussed at https://www.stata.com/support/faqs/d...ble-recording/

              This code is not tested but I think it's pointing in a good direction.

              Code:
              egen max = max(ind), by(company) 
              
              egen min = min(id), by(company) 
              
              egen tag = tag(company)
              Code:
              * any value > 50 
              list company if max > 50 & max < . & tag, noobs 
              
              * all values > 50 
              list company if min > 50 & min < . & tag, noobs

              Comment


              • #8
                Thank you for your answer. It helped me a lot

                Comment

                Working...
                X