Announcement

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

  • Data Splitting into 5 Quintiles based on Alphabetic Order Company Names

    Is there a way I can split the Turnover values as follows so that each quintile has 20% of the firm-year data? I need to take the top 20% quintile comprises of an alphabetic order company name list.

    Click image for larger version

Name:	Capture.PNG
Views:	3
Size:	18.9 KB
ID:	1689467



  • #2

    Code:
    egen group = group(company_name), label 
    su group, meanonly 
    gen first_alpha_quintile = group < r(max)/5

    Comment


    • #3
      Thank you so much Nick

      Comment


      • #4
        The above code is worked for the whole database. Thanks a lot Nick Cox .
        One small thing I would like to know further relating to the above example, as observations are from 1999 to 2012, how can I split them into Quintile 1 & Quintiles 2 to 5 separately for each year?

        This also takes the top 20% quintile of an alphabetic order company name list (Quintile 1)
        The remaining 80% quintile of an alphabetic order company name list (Quintile 2 to 5)

        Not for firm-year observations, I want to get two quintiles yearly basis.

        Thank you.
        Last edited by Hirindu Kawshala; 23 Dec 2022, 10:53.

        Comment


        • #5
          This also takes the top 20% quintile of an alphabetic order company name list (Quintile 1)
          The remaining 80% quintile of an alphabetic order company name list (Quintile 2 to 5)

          Not for firm-year observations, I want to get two quintiles yearly basis.

          Thank you.

          Comment


          • #6
            Code:
            ssc install egenmore 
            
            egen quintile = xtile(Turnover), by(year) nq(5) 
            
            replace quintile = min(quintile, 2)

            Comment


            • #7

              Thanks you Nick Cox. As you mentioned, below command is worked for firm-year observations. egen group = group(company_name), label su group, meanonly gen first_alpha_quintile = group < r(max)/5
              Now I wanted to get above two quintiles yearly basis.This also takes the top 20% quintile of an alphabetic order company name list (Quintile 1) and the remaining 80% quintile of an alphabetic order company name list (Quintile 2 to 5) How can get yearly basis, - quintile 1 - remaining quintiles 2 to 5 together

              Comment


              • #8

                Thanks you Nick Cox.

                As you mentioned earlier, below command is worked for firm-year observations (For 1999 to 2012)
                egen group = group(company_name) label
                su group, meanonly
                gen first_alpha_quintile = group < r(max)/5

                Can you please let me knwo,how can get yearly basis,
                1999
                Quintile 1 = First 20% of Alphabetic Company Names = Q1
                Quintile 2 = Remaining 80% of Alphabetic Company Names = Q2

                2000
                Quintile 1 = First 20% of Alphabetic Company Names =Q1
                Quintile 2 = Remaining 80% of Alphabetic Company Names =Q2

                And then, for Q1 seperately mean, median & for Q2 seperately mean, median

                Thank you.
                Last edited by Hirindu Kawshala; 23 Dec 2022, 12:22.

                Comment


                • #9
                  What point is there in quantiles of alphabetical order? An idea that Aardvark Electronics has a competitive edge over Zebra Zoo Products?

                  Seriously, it will be some variation on principles already explained.

                  Comment


                  • #10
                    It's just a simple modification of what you already have, derived from Nick's response in #2:
                    Code:
                    egen group = group(company_name) label
                    by year (group), sort: gen first_alpha_quintile = (_n < _N/5)
                    By the way, reading this thread, there is some unclarity in exactly what is wanted. In #1 you refer to quintiles based on the numeric variable Turnover, and then to quintiles based on alphabetical order of company name. This unclarity persists in the thread, as, for example, in #6 where Nick's code generates Turnover quintiles. All in all, I'm not entirely sure which kind of quintiles you want.

                    Added: Crossed with #9.

                    Comment


                    • #11
                      I have data on total firm-year observations.
                      Number of Companies (15,224),
                      and Period (1999-2012)

                      Out of the total number of companies, the first 20%, according to the alphabetic rank, goes to the 1st Quintile each year.
                      Out of the total number of companies, the remaining 80%, according to the alphabetic rank, goes to the 2 to 5 Quintile each year.

                      Comment


                      • #12
                        Yes, it worked Clyde Schechter Thanks a lot. Exactly, this is the code I searched for.

                        Comment

                        Working...
                        X