Announcement

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

  • HELP with Stata Graphics

    Dear Statalisty,

    I am really struggling with generating graphs in Stata.
    For the dataset below (which in complete consists of many years) I need the mean for total_dir, typI, typL, typE and n_indep per year as a vertical bar chart.

    As in each line total_dir is the sum of typI, -L and -E, it would be nice if there are all are in one bar per year separated by color.

    Does anyone have an idea? Thanks!


    Code:
    clear
    input float year long permno double didown float(total_dir typI typL typE n_indep)
    1996 10016  4337000  8 3 2 3 3
    1996 10035 20143600  6 2 3 1 2
    1996 10048  3367000  9 3 1 5 3
    1996 10062 20128400 11 1 9 1 1
    1996 10064 20155100 11 3 5 3 3
    1996 10071 20001800  9 6 0 3 6
    1996 10078     2426  7 5 1 1 5
    1996 10104     6038  6 2 1 3 2
    1996 10107  3362600  8 5 2 1 5
    1996 10108     1459  8 5 2 1 5
    end

  • #2
    Something like this?
    Code:
    graph bar total_dir typI typL typE n_indep, over(year)

    Comment


    • #3
      Code:
      graph bar typI typL typE n_indep, over(year) stack
      may be a little closer to what you want. You shouldn't want to include the total twice.
      Last edited by Nick Cox; 05 Nov 2019, 08:22.

      Comment


      • #4
        Thank you! It works.

        What option should I choose so that the var labels are in the legend instead of the var names?

        Comment


        • #5
          You can control the legend entries directly. Or collapse to a dataset of means, in which case graph bar (asis) should pick up variable labels directly.

          Comment

          Working...
          X