Announcement

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

  • How to find top 25% Top industries within the sample

    Hello Stata Experts,

    I am stuck up in a simple question. Before asking the question, I will clarify what I have done and what I want to find.
    First, I found top 25% export intensive industries from my data set using the loop command in Stata "foreach v of varlist *_intensity {
    centile `v', centile(75)
    gen byte top_25_pct_`v' = `v' > `r(c_1)' if !missing(`v')
    }".

    And sort the export intensive industry, copy the data, which is only 25% export-intensive industries, into another Stata sheet. Now, We want to find particular industries which belong to the top 25% export intensive industry after collapsing the data with id and qdate. For example, id==2|id==3|id==9|id==16, these industries are top 25% export -intensive industry that we know. But my question is how can I find out top 25% export-intensive industries within the data set or which methodology like "tab or list" should I use?

    Any suggestions and guidelines warmly received!

    input float(id qdate export_intensity) byte top_25_pct_export_intensity str154 industry
    1 227 1.4445505 1 "B07. (Mining Of Metal Ores)"
    1 228 1.896488 1 "B07. (Mining Of Metal Ores)"
    1 229 1.6249745 1 "B07. (Mining Of Metal Ores)"
    1 230 1.3728193 1 "B07. (Mining Of Metal Ores)"
    1 231 1.433978 1 "B07. (Mining Of Metal Ores)"
    2 208 1.324223 1 "C10. (Manufacture Of Food Products)"
    2 209 1.307073 1 "C10. (Manufacture Of Food Products)"
    2 216 1.42768 1 "C10. (Manufacture Of Food Products)"
    2 217 1.3556803 1 "C10. (Manufacture Of Food Products)"
    2 218 1.386819 1 "C10. (Manufacture Of Food Products)"
    2 220 1.75476 1 "C10. (Manufacture Of Food Products)"
    2 221 1.7779745 1 "C10. (Manufacture Of Food Products)"
    2 222 1.8739676 1 "C10. (Manufacture Of Food Products)"
    2 223 1.366078 1 "C10. (Manufacture Of Food Products)"
    2 224 1.7455617 1 "C10. (Manufacture Of Food Products)"
    2 225 1.5929006 1 "C10. (Manufacture Of Food Products)"
    2 226 1.6958264 1 "C10. (Manufacture Of Food Products)"
    2 227 1.2985034 1 "C10. (Manufacture Of Food Products)"
    2 228 1.850037 1 "C10. (Manufacture Of Food Products)"
    2 229 1.7699642 1 "C10. (Manufacture Of Food Products)"
    2 230 1.6345984 1 "C10. (Manufacture Of Food Products)"
    2 231 1.34356 1 "C10. (Manufacture Of Food Products)"
    3 207 1.516173 1 "C11. (Manufacture Of Beverages)"
    3 208 1.517135 1 "C11. (Manufacture Of Beverages)"
    3 211 1.5075828 1 "C11. (Manufacture Of Beverages)"
    3 212 1.59864 1 "C11. (Manufacture Of Beverages)"
    3 215 1.730888 1 "C11. (Manufacture Of Beverages)"
    3 216 1.832001 1 "C11. (Manufacture Of Beverages)"
    3 219 1.8057833 1 "C11. (Manufacture Of Beverages)"
    3 220 1.8706665 1 "C11. (Manufacture Of Beverages)"
    3 221 1.4094888 1 "C11. (Manufacture Of Beverages)"
    3 222 1.3859913 1 "C11. (Manufacture Of Beverages)"
    3 223 1.8859833 1 "C11. (Manufacture Of Beverages)"
    3 224 2.0369089 1 "C11. (Manufacture Of Beverages)"
    3 225 1.4522846 1 "C11. (Manufacture Of Beverages)"
    3 226 1.4526154 1 "C11. (Manufacture Of Beverages)"
    3 227 2.240903 1 "C11. (Manufacture Of Beverages)"
    3 228 2.3553765 1 "C11. (Manufacture Of Beverages)"
    3 229 1.7260377 1 "C11. (Manufacture Of Beverages)"
    3 230 1.4958856 1 "C11. (Manufacture Of Beverages)"
    3 231 2.130134 1 "C11. (Manufacture Of Beverages)"
    4 207 1.3299427 1 "C12. (Manufacture Of Tobacco Products)"
    4 216 1.5140954 1 "C12. (Manufacture Of Tobacco Products)"
    4 220 1.4182765 1 "C12. (Manufacture Of Tobacco Products)"
    4 222 1.4058793 1 "C12. (Manufacture Of Tobacco Products)"
    4 224 1.609543 1 "C12. (Manufacture Of Tobacco Products)"
    4 225 1.3651093 1 "C12. (Manufacture Of Tobacco Products)"
    4 226 1.5278707 1 "C12. (Manufacture Of Tobacco Products)"
    4 227 1.3807752 1 "C12. (Manufacture Of Tobacco Products)"
    4 228 2.0812523 1 "C12. (Manufacture Of Tobacco Products)"
    4 229 1.9339756 1 "C12. (Manufacture Of Tobacco Products)"
    4 230 1.746653 1 "C12. (Manufacture Of Tobacco Products)"
    4 231 1.5047008 1 "C12. (Manufacture Of Tobacco Products)"
    5 206 1.298354 1 "C13. (Manufacture Of Textiles)"
    5 220 1.3595273 1 "C13. (Manufacture Of Textiles)"
    5 221 1.3090048 1 "C13. (Manufacture Of Textiles)"
    5 222 1.5072513 1 "C13. (Manufacture Of Textiles)"
    5 224 1.3980492 1 "C13. (Manufacture Of Textiles)"
    5 225 1.3064367 1 "C13. (Manufacture Of Textiles)"
    5 226 1.5619996 1 "C13. (Manufacture Of Textiles)"
    5 227 1.399169 1 "C13. (Manufacture Of Textiles)"
    5 228 1.662975 1 "C13. (Manufacture Of Textiles)"
    5 229 1.5900215 1 "C13. (Manufacture Of Textiles)"
    5 230 1.620593 1 "C13. (Manufacture Of Textiles)"
    5 231 1.5424703 1 "C13. (Manufacture Of Textiles)"
    6 216 1.3560317 1 "C14. (Manufacture Of Wearing Apparel)"
    6 228 1.464375 1 "C14. (Manufacture Of Wearing Apparel)"
    6 229 1.340105 1 "C14. (Manufacture Of Wearing Apparel)"
    7 220 1.3941725 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    7 222 1.297012 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    7 224 1.400813 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    7 228 1.489629 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    7 229 1.294744 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    7 230 1.3102505 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    7 231 1.328538 1 "C16. (Manufacture Of Wood And Of Products Of Wood And Cork, Except Furniture; Manufacture Of Articles Of Straw And Plaiting Materials)"
    9 200 1.3245287 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 205 1.3036696 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 206 1.3261174 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 207 1.5070226 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 208 1.719437 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 209 1.5204036 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 210 1.3453947 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 211 1.397354 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 212 1.8626986 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 213 1.3918545 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 214 1.483471 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 215 1.5985292 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 216 2.0443542 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 217 1.9285 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 218 1.662864 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 219 1.334296 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 228 1.3173786 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    9 231 1.6225357 1 "C19. (Manufacture Of Coke And Refined Petroleum Products)"
    10 216 1.358629 1 "C20. (Manufacture Of Chemicals And Chemical Products)"
    10 218 1.340243 1 "C20. (Manufacture Of Chemicals And Chemical Products)"
    10 219 1.3944882 1 "C20. (Manufacture Of Chemicals And Chemical Products)"
    10 220 1.4226228 1 "C20. (Manufacture Of Chemicals And Chemical Products)"
    10 221 1.391964 1 "C20. (Manufacture Of Chemicals And Chemical Products)"
    10 222 1.5634558 1 "C20. (Manufacture Of Chemicals And Chemical Products)"
    10 223 1.547672 1 "C20. (Manufacture Of Chemicals And Chemical Products)"

  • #2
    Hello Muhammad. Does the following give you what you want?

    Code:
    foreach v of varlist *_intensity {
      quietly summarize `v', detail
      gen byte top_25_pct_`v' = `v' > r(p75) if !missing(`v')
    }
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

    Comment


    • #3
      Originally posted by Bruce Weaver View Post
      Hello Muhammad. Does the following give you what you want?

      Code:
      foreach v of varlist *_intensity {
      quietly summarize `v', detail
      gen byte top_25_pct_`v' = `v' > r(p75) if !missing(`v')
      }

      Hi Bruce,

      It gives me an overall 25% export intensive industries. But I want to find out exactly which industries and thier id are within 25% export intensive industries after collapse, for example, id==2|id==3|id==9|id==16 are top 25%.

      How can I find out/list/Tab the id after collapse the data?

      Thanks for your reply!

      Comment


      • #4
        Is this what you're after?

        Code:
        sort id top_25_pct_export_intensity
        by id: replace top_25_pct_export_intensity = top_25_pct_export_intensity[_N]
        by id: generate byte firstrec = _n==1.
        list id if firstrec & top_25_pct_export_intensity, clean
        Output (using the data you posted earlier and the code I posted earlier):

        Code:
        . list id if firstrec & top_25_pct_export_intensity, clean
        
               id  
          1.    1  
          6.    2  
         23.    3  
         42.    4  
         76.    9
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment

        Working...
        X