Announcement

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

  • Generating a variable for TOP 4 market share

    I would like to generate a variable that links a summarized market share of 4 biggest companies (TOP4) in a particular industry to every company in this industry.
    I need this variable as a measure of competitiveness of an industry in which a particular company operates.

    I have a database of companies and every company is in one industry. Industries are represented by integers from 1 to 99.
    In one observation I have: CompanyID, Industry, MarketShare.

    Here is an example:
    CompanyID Industry MarketShare TOP4
    1 1 40% 40%+25%+15%+10% = 90%
    2 1 25% 90%
    3 1 15% 90%
    4 1 10% 90%
    5 1 5% 90%
    6 1 5% 90%
    7 2 30% 30%+30%+20%+15%=95%
    8 2 30% 95%
    9 2 20% 95%
    10 2 15% 95%
    11 2 5% 95%
    How can I generate a TOP4 variable using Stata? I think that I have to use
    Code:
     bys Industry:
    and then somehow sort the shares and sum the biggest four.


    Thank you for your help.


  • #2
    Code:
    gsort Industry -MarketShare
    by Industry: egen top4 = total(MarketShare*(_n<=4))
    will work for data that is similar to your example. It is less clear what you want to do if there is tied market share between #4 and #5 in an industry. This code will count the share of one, but not both of those.

    Comment


    • #3
      Thank you for your quick response. It works!
      And if I would have a panel data with a variable Year, should I modify this as following?:
      Code:
      gsort Industry Year -MarketShare
      by Industry Year: egen top4 = total(MarketShare*(_n<=4)

      Comment


      • #4
        Assuming you want a separate top 4 for each industry in each year, then yes, that is exactly what you should do. (Except that you are missing a closing parenthesis at the end of the by...:.. command.)

        Comment


        • #5
          Thank you for your help!

          Comment


          • #6
            Dear Clyde,

            I have a panel data which comprise of firms operating in numerous countries for 13 years. I would like to generate a variable called "market share instability" that is is measured by the sum of the absolute value of the annual market share changes, divided by the initial market share for each of the leading (top) four firms. The formula can be found on the attachment. I would be grateful if you could help me with the command.


            Click image for larger version

Name:	msi.png
Views:	3
Size:	5.5 KB
ID:	1385580


            Comment


            • #7
              This is not related to the original topic of this thread. So please re-post in a new thread so that people who are searching for things related to TOP 4 won't have their time wasted on this part of the thread, and so that people interested in this new question will be able to find it!

              Also, the approach to this problem would depend on how your data are currently organized. So to get a specific answer, you need to use the -dataex- command to show an example of your data. You can install -dataex- by running -ssc install dataex-. Then run -help dataex- to read the simple instructions for using it.

              Finally, the graphic containing the formula you posted is very small and difficult to read. After I opened it in a separate window, I see that it contains subscripts and superscripts. You will need to explain how those correspond to variables in the example data set you post.

              Comment


              • #8
                Thank you very much for your response and suggestions, I have just opened a new threat regarding this variable.

                Comment


                • #9


                  good day, please how can i generate top 20% for a variable

                  Comment


                  • #10
                    ighoiye fortune This may help.

                    Code:
                    . sysuse auto, clear
                    (1978 Automobile Data)
                    
                    . xtile binned=mpg, nq(5)
                    
                    . table binned, c(min mpg max mpg)
                    
                    ----------------------------------
                    5         |
                    quantiles |
                    of mpg    |   min(mpg)    max(mpg)
                    ----------+-----------------------
                            1 |         12          17
                            2 |         18          19
                            3 |         20          22
                            4 |         23          25
                            5 |         26          41
                    ----------------------------------
                    
                    . gen top20pc = binned == 5
                    If you want something different, you may need to give more detail on what.

                    Comment


                    • #11
                      thanks, i am using a data on co2 which is continuous with 174 obs, I am trying to create the highco2 i.e. top 20% with highest co2 emission

                      Comment

                      Working...
                      X