Announcement

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

  • Graph for frequency of a dummy variable over the years

    Hello everyone,

    I have a crosssectional panel data set and I want to create a graph which displays the number of sanctions imposed for every year. Sanctions is a dummy variable in this case. Does anyone know, how to do this?

    I already did a lot of research but couldn't find a solution for my problem.

    Best wishes,

    Niklas

  • #2

    At a wild guess you want something like

    Code:
    graph bar (sum) sanctions, over(year)
    You can get more control with

    Code:
    egen sum = total(sanctions), by(year) 
    twoway bar sum year 

    Comment


    • #3
      Dear Nick,

      The first one didn't work for me (even tried it before), but the second did just fine.
      Thanks alot for your fast help!

      Best wishes,

      Niklas

      Comment


      • #4
        Good, except insofar as without a data example, exact code, or explanation of "didn't work", I can't guess what went wrong. Please do read the FAQ Advice before your next thread, where all these points are covered.

        Comment


        • #5
          Sorry for that, I will do so the next time. As for this case, the first suggestion made the years unreadable.
          the second one made it more smooth.
          I added both as an attachment, in case you are interested in it.

          Best wishes,

          Niklas
          Attached Files

          Comment


          • #6
            OK; so "didn't work" meant "not what I wanted". Understood.

            Comment

            Working...
            X