Announcement

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

  • Displaying number of observations on a graph title

    Hi there,

    I want to put the number of observations in the title of a bar graph that displays the percentage distribution of the observation over a few categories, but I can't find a way to do it. I'm using this command for the graph:

    graph bar (percent) var1, over(var2)ytitle(% of `: variable label var1') blabel(bar)

    I tried using title(var1 Rate `: var1[r(sum)]'),but apparently it doesn't work.

    Thank you,




  • #2
    So, I'm assuming that you want to include in the title the number of observations of var1. You can do that as follows:

    Code:
    count if !missing(var1)
    local N `r(N)'
    graph bar (percent) var1, over(var2) ytitle(% of `:variable label var1') ///
        blabel(bar) title("N = `N'")

    Comment


    • #3

      Exactly, Clyde! I'm sorry for not being clear about what variable I was talking about. The graph looks like this thanks to you:


      Click image for larger version

Name:	acceptance_rate.gif
Views:	1
Size:	24.4 KB
ID:	1431777


      Comment

      Working...
      X