Announcement

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

  • Catplot with bars over different sectors - make each bar's percentage add up to 100%

    Dear All,

    I generated a catplot with the following code:

    Code:
    catplot question1, over(sector) stack asyvar percent 
    blabel(bar, position(center) format(%3.1f) size(half_tiny)) 
    ysize(20) xsize(20)
    The graph shows the percentage of each answer of a survey question for different sectors (sectors 15-72, each bar represent one sector). As shown in the graph attached, I found out the percentage of each bar does not add up to 100%, I guess it's because Stata count all of the sectors together as 100% instead of each individual one as 100%.

    I also tried generating the graph for each sector separately then combine the individual graphs together, it worked, but the graph with over 30 subgraphs is not as good-looking as just having bars as each sector. So I still would like to use the below graph form. I'm wondering if there is a way to make the percentage of each bar to 100%.

    Any help will be appreciated!

    Thank you very much for your time!

    Best,
    Craig
    Click image for larger version

Name:	Screen Shot 2020-02-18 at 4.47.24 PM.png
Views:	1
Size:	675.0 KB
ID:	1537241




  • #2
    catplot is from SSC, as you are asked to explain (FAQ Advice #12).

    percent with no argument means % of all observations shown. Nothing needs to be guessed or found out here: this is documented in the help. I think you want percent(sector)

    Comment


    • #3
      Hi Nick,

      Thank you very much for your help! It worked perfectly. I'll read the documentation more carefully in the future.

      Thank you,
      Craig

      Comment

      Working...
      X