Announcement

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

  • Plotting a line graph of dummy variables

    Hello,

    I would like to create a line graph from 1995 to 2021 for three different dummy variables. The lines should show the count of each dummy variable by the time when these variables are equal to 1. Each observation has a unique id and a year attached to it, also each of these observations has only one of these 3 dummies as equal to 1. What I want is to see the evaluation of each group by the time. Thanks in advance.

    Best,
    Ulku

  • #2
    Assuming standard 0/1 coding:

    Code:
    preserve
    collapse (sum) dummy1 dummy2 dummy3, by(time)
    line dummy1 dummy2 dummy3 time, sort
    restore

    Comment


    • #3
      Thank you so much! It worked perfectly fine.

      I have another question. If we consider each of these dummies as one category, I want to look at the mean of another variable by time in these three different categories. How could I do that?

      For example, dummies are region1, region2, and region3, and I want to look at how the average number of teachers in these regions has changed over time.

      Best,
      Ulku

      Comment


      • #4
        Provide a data example using dataex. See FAQ Advice #12 for details.

        Comment

        Working...
        X