Announcement

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

  • Rounding off on graph

    Dear Stata users,

    I am sure this thread might have been posted earlier, but I am unable to understand though I did a quick check with this thread https://www.statalist.org/forums/for...decimal-places .

    My query is how could i get rounding off figures as labels on the graph as my labels should match with the tables. I have used the following syntax for running a graph and Its result is attached here. Can anyone help me out to add an option to take care of rounding off the figure (for eg; 0.00 to 0)

    graph hbar (mean) income_agri_yearly if n==1 & consent ==1 & income_agri_yearly !=0 [aweight = trimweight], over(socialgroup_hhm) blabel(bar) legend(on) name(AgriculturalIncome) title(Agricultural Income)

    Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	52.5 KB
ID:	1691561



  • #2
    The blabel allows for a format suboption. See
    Code:
    help blabel_option

    Comment


    • #3
      Hello Hemanshu, thanks for the suggestion. I tried your way but got an error 198.

      Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	25.5 KB
ID:	1691567

      Comment


      • #4
        Well, I realized that I made a mistake. I should have put the format inside the blabel().

        Comment


        • #5
          I am still getting the decimal numbers as a label for this command

          graph hbar (mean) income_agri_yearly if n==1 & consent ==1 & income_agri_yearly !=0 [aweight = trimweight], over(socialgroup_hhm) blabel(total, position(inside) color(white) format(%9.1f)) legend(on) name(AgriculturalIncome2) title(Agricultural Income)

          How to get only the whole number?
          Attached Files

          Comment


          • #6
            You asked for a display rounding to 1 decimal place and you got what you asked for. You can round to integers by using e.g. %9.0f. If you wanted more vigorous rounding to be shown with graph bar you would need to create a new variable that was rounded to the nearest hundred or thousand or whatever you wanted.

            You say that you want presentation to be consistent with what is shown in tables. but as you don't explain what is shown in your tables it is hard to advise there.

            Comment


            • #7
              Dear Nick,

              I am sorry for the unclear and misinformation thread.

              And appreciate much for your kind explanation. It worked well, hurray!!.

              Comment

              Working...
              X