Announcement

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

  • Pie Chart

    Hi, I want to create a pie chart in the same way like in the link below

    https://imaa-institute.org/m-and-a-by-industries/

    Kindly help how to do this.

    My data is Like this,

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str30 AcquirorMacroIndustry double Percent
    "Industrials"                                          20.28
    "Materials"                                           13.42
    "Consumer Products and Services"    13.22
    "High Technology"                                9.84
    "Healthcare"                                         8.55
    "Financials"                                          8.05
    "Media and Entertainment"                  6.96
    "Consumer Staples"                            5.17
    "Energy and Power"                            4.77
    "Real Estate"                                       4.37
    "Telecommunications"                        3.28
    "Retail"                                                2.09
    ""                                   .
    end


  • #2
    Maybe something like the following.
    Code:
    version 15.1
    
    clear *
    
    input str30 AcquirorMacroIndustry double Percent
    "Industrials"                    20.28
    "Materials"                      13.42
    "Consumer Products and Services" 13.22
    "High Technology"                 9.84
    "Healthcare"                      8.55
    "Financials"                      8.05
    "Media and Entertainment"         6.96
    "Consumer Staples"                5.17
    "Energy and Power"                4.77
    "Real Estate"                     4.37
    "Telecommunications"              3.28
    "Retail"                          2.09
    ""                                   .
    end
    
    drop if mi(Percent )
    generate byte row = _n
    generate byte col = 1
    quietly reshape wide AcquirorMacroIndustry Percent , i(col) j(row)
    foreach var of varlist Percent* {
        local number : subinstr local var "Percent" "", all
        local varlabel = AcquirorMacroIndustry`number'[1]
        label variable `var' "`varlabel'"
    }
    
    graph pie P*
    quietly graph export pie.png
    
    exit
    Click image for larger version

Name:	pie.png
Views:	1
Size:	38.6 KB
ID:	1492208

    Comment

    Working...
    X