Announcement

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

  • Creating histograms for discrete variable for Treatments next to each other

    Hi Everyone,

    I have the following data.

    T1_Success --> Number of correct answers
    Treatment --> Treatment assigned

    I want to make histogram of T1_success across treatments. However, I don't want it to be overlapping like the one generated by twoway histogram command.

    I want the histogram bars next to each other for each treatment. For instance, for number of correct answers = 5, I want all histogram bars (one for each treatment) to be shown next to each other. Similarly, for number of correct answers =6 , I want all histogram bars (one for each treatment) to be shown next to each other and so on.

    Any help or link for such an example will be much appreciated.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(T1_success Treatment)
    5 3
    5 3
    5 3
    5 2
    5 2
    5 1
    9 3
    9 2
    9 2
    9 1
    4 3
    4 3
    4 3
    4 3
    4 1
    4 2
    4 2
    8 3
    end
    label values Treatment Treatment
    label def Treatment 3 "Election (N=96)", modify

  • #2
    Something like the solution here?

    Comment


    • #3
      Thank you so much. It worked.

      Comment


      • #4
        For a write-up of Hemanshu's method see https://www.stata-journal.com/articl...article=gr0026

        Comment

        Working...
        X