Announcement

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

  • Drawing a bar graph with sums over a categorical variable

    Hello Stata people;

    I have this data at hand that I'm working with currently:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double imptd str37 secteurdactivit
           0 "05 ACTIVITES INDUSTRIELLES"           
           0 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "05 ACTIVITES INDUSTRIELLES"           
     2544360 "04 ACTIVITES DE PRESTATION DE SERVICE"
      117520 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
     1851460 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "03 ACTIVITES DE COMMERCE EN GROS"     
      300000 "03 ACTIVITES DE COMMERCE EN GROS"     
      300000 "03 ACTIVITES DE COMMERCE EN GROS"     
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "05 ACTIVITES INDUSTRIELLES"           
      300000 "05 ACTIVITES INDUSTRIELLES"           
           0 "05 ACTIVITES INDUSTRIELLES"           
           0 "06 ACTIVITES NON COMMERCIALES"        
      300000 "06 ACTIVITES NON COMMERCIALES"        
      300000 "06 ACTIVITES NON COMMERCIALES"        
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      494000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      314860 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
     4353600 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "05 ACTIVITES INDUSTRIELLES"           
    25130550 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
       15080 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "04 ACTIVITES DE PRESTATION DE SERVICE"
           0 "04 ACTIVITES DE PRESTATION DE SERVICE"
      300000 "06 ACTIVITES NON COMMERCIALES"        
      300000 "06 ACTIVITES NON COMMERCIALES"        
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      910000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
           0 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      427960 "04 ACTIVITES DE PRESTATION DE SERVICE"
     1455220 "07 ACTIVITES AGRICOLES ET DE PECHE"   
    42481450 "07 ACTIVITES AGRICOLES ET DE PECHE"   
      300000 "05 ACTIVITES INDUSTRIELLES"           
    21552500 "07 ACTIVITES AGRICOLES ET DE PECHE"   
    62658950 "07 ACTIVITES AGRICOLES ET DE PECHE"   
     2587000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
     1817400 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
     1147380 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "02 ACTIVITES DE COMMERCE EN DETAIL"   
           0 "02 ACTIVITES DE COMMERCE EN DETAIL"   
      300000 "03 ACTIVITES DE COMMERCE EN GROS"     
     8244000 "03 ACTIVITES DE COMMERCE EN GROS"     
      300000 "03 ACTIVITES DE COMMERCE EN GROS"     
     2158000 "03 ACTIVITES DE COMMERCE EN GROS"     
    end
    The data is about tax filing for about 150 000 people (here, it is just an example of the data). The database has two variables: "imptd" which is the annual tax that the person paid, and "secteurdactivit" which is about the sector of activity of that same person (the domain of work).
    My goal is to have a bar grapg that shows the total of annual paid taxation by the sector of activity. I probably need to divise the "imptd" variable by 1 000 000 since it is expressed in Tunisian millimes.

    Any help please?

    With many thanks!

  • #2
    This question isn't much different from your recent question at https://www.statalist.org/forums/for...-and-two-dates

    The main difference is wanting the command to start

    Code:
    graph hbar (sum) 

    Comment


    • #3
      Nick Cox Thanks for the help, the idea of the code workd, it gave me the graph I wanted. But I guess there is a problem with my values, since the values of the Y axis of the graph were expressed in the "scientific format". I guess since my values are expressed in Tunisian millimes (which is like the American cent), I should express those values in million dinars and divide them in order to get a better graph

      Comment

      Working...
      X