Announcement

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

  • multiple independent variables in same bar graph

    My data contains values of the wages of people in three different years, some of them recieved job training (program group) some didn't (control). I'd like to generate a bar graph showing the average wage of the program group next to the average wage of the control group for all three years next to each other. I couldn't find anything that works, the closest I came was using

    graph bar wage1 wage2 wage3, over(prog)

    but then then I have three bars of the mean of the wage of the people in the program group on the right and three bars of the mean of the wage of the people in the control group on the left. I, however, want to have mean(wage1) of program vs control to the right, then wage2 in the middle and wage 3 to the left. Is there any possibility of doing this?

    Thanks a lot for any help


  • #2
    Data example and graph please.

    Comment


    • #3
      I couldn't make a data example from the data I used, but this should show the same problem:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int(prog engage1 engage2 engage3)
      1  3  4  4
      1  5  3 -5
      1  6 -5 -5
      1  4  4  6
      0  4 -5 -5
      1  4 -5  5
      0  3  5  4
      1  4  2  6
      0 -5 -5 -5
      1  5  3  6
      end
      label values prog PROGRAM
      label def PROGRAM 0 "(0) Comparison", modify
      label def PROGRAM 1 "(1) Program", modify
      label values engage1 B1V3CENG
      label def B1V3CENG -5 "-5/.E=missing item", modify
      label values engage2 B2V3CENG
      label def B2V3CENG -5 "-5/.E=missing item", modify
      label values engage3 B3V3CENG
      label def B3V3CENG -5 "-5/.E=missing item", modify
      The first column shows the assignment program/control, the other three show variables of engagement, all collected at different points in time.

      If I use

      graph bar engage1 engage2 engage3, over(prog)

      I get following graph:

      Click image for larger version

Name:	Graph.png
Views:	1
Size:	13.0 KB
ID:	1396274


      The first problem is I'd like to have the blue bars next to each other, then the red ones and then the green ones.

      The second problem I just noticed is that the -5 (indicating missing values) shouldn't be counted when the values of the graphs are calculated. I don't want to delete all observations if any of the three variables has a missing value because I could still use the ones that do exist (eg. in engage1 is missing for a particular observation it might still have values for engage2 and engage3)

      Thanks for your help and sorry I didn't include everything straight away

      Comment


      • #4
        Thanks for the examples.

        See e.g. statplot (SSC) (search the forum for mentions) and the following code

        Code:
        mvdecode engage?, mv(-5)
        
        ssc inst statplot
        .
        statplot engage? , over(prog)
        statplot engage? , over(prog) recast(bar)
        statplot engage? , over(prog) recast(dot)
        statplot engage? , over(prog) recast(dot) vertical
        statplot engage? , over(prog) recast(dot) vertical asyvars

        Comment


        • #5
          Thank you so much

          Comment

          Working...
          X