Announcement

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

  • Combining two bar graphs

    Dear Statalist,

    I have now used nine hours today reading every thread, watching every Youtube video but without succes. By demand is simple and it is easy to do in for example Excel. Yet, I simply cannot do it in Stata.

    I have a dataset with responses BEFORE a crisis and AFTER a crises. The answer categories are the same. I just want to create one graph, showing the two different responses in each category. It is simple discriptive statistics.

    My data is this:
    strat1_before strat1_after
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Never
    Never Less than once a month
    Never Less than once a month
    Never Once a month
    Never .
    Never .
    Never .
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Less than once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month Once a month
    Less than once a month More than once a week
    Once a month Never
    Once a month Less than once a month
    Once a month Less than once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a month
    Once a month Once a week
    Once a month Once a week
    Once a month Once a week
    Once a month Once a week
    Once a month Once a week
    Once a week Once a month
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week Once a week
    Once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week
    More than once a week More than once a week

    I have managed to create two seperate graphs:

    Click image for larger version

Name:	Billede1.png
Views:	1
Size:	43.3 KB
ID:	1751112


    But I need to combine them: Same five categories, but with two different bars. Preferably in two different colours.

    Thanks in advance,
    Andreas Esbjørnsen

  • #2
    Please familiarize yourself with the dataex command for presenting data examples.

    Code:
    help dataex
    The fact that you have "." values implies that these are numerical variables with value labels and not string variables. Here, I will assume that they are strings.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str22(strat1_before strat1_after)
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Never"                 
    "Never"                  "Less than once a month"
    "Never"                  "Less than once a month"
    "Never"                  "Once a month"          
    "Never"                  "."                     
    "Never"                  "."                     
    "Never"                  "."                     
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Less than once a month"
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "Once a month"          
    "Less than once a month" "More than once a week" 
    "Once a month"           "Never"                 
    "Once a month"           "Less than once a month"
    "Once a month"           "Less than once a month"
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a month"          
    "Once a month"           "Once a week"           
    "Once a month"           "Once a week"           
    "Once a month"           "Once a week"           
    "Once a month"           "Once a week"           
    "Once a month"           "Once a week"           
    "Once a week"            "Once a month"          
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "Once a week"           
    "Once a week"            "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    "More than once a week"  "More than once a week" 
    end
    
    
    gen long obsno=_n
    reshape long  strat1_@, i(obsno) j(which) string
    drop if strat1_=="."
    graph hbar (count), over(which) over(strat1_, sort(1)) asyvars
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	21.4 KB
ID:	1751119

    Comment


    • #3
      Thank you so much, Andrew!

      What do I do, if want the graph in the following order: Never, Less than once a month, Once a month, Once a week, More than once a week?

      Thanks in advance,

      Andreas Esbjørnsen

      Comment


      • #4
        You will want to create a numerical variable =1 if "Never", ..., = 5 if "More than once a week", and use this variable to plot.

        Code:
        search labmask
        which will allow you to label the values of this variable with values of the variable strat1_. Below, I do it directly as there is no such variable in the dataset I have.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input str22(strat1_before strat1_after)
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Never"                 
        "Never"                  "Less than once a month"
        "Never"                  "Less than once a month"
        "Never"                  "Once a month"          
        "Never"                  "."                     
        "Never"                  "."                     
        "Never"                  "."                     
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Less than once a month"
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "Once a month"          
        "Less than once a month" "More than once a week" 
        "Once a month"           "Never"                 
        "Once a month"           "Less than once a month"
        "Once a month"           "Less than once a month"
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a month"          
        "Once a month"           "Once a week"           
        "Once a month"           "Once a week"           
        "Once a month"           "Once a week"           
        "Once a month"           "Once a week"           
        "Once a month"           "Once a week"           
        "Once a week"            "Once a month"          
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "Once a week"           
        "Once a week"            "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        "More than once a week"  "More than once a week" 
        end
        
        
        gen long obsno=_n
        reshape long  strat1_@, i(obsno) j(which) string
        drop if strat1_=="."
        local order `" "Never" "Less than once a month"  "Once a month" "Once a week"  "More than once a week" "'
        gen order=.
        local i 0
        lab values order order
        foreach cat of local order{
            local ++i
            replace order=`i' if strat1_=="`cat'" 
            lab def order `i' "`cat'", modify
        }
        graph hbar (count), over(which) over(order) asyvars
        Res.:

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	21.4 KB
ID:	1751143

        Comment


        • #5
          Thank you for your response, Andrew.

          I do get an error message ( type mismatch r(109), and I can see that you are using a lot of advanced commands that I am not familiar with.

          Is it in any way possible to do this using more simple commands such as "recode" that I am familiar with. I do not mind the extra work as long as I understand it and it works.

          I am going to reproduce this sort of graph many times in my paper, showing the difference between 'before' and 'after' answers.

          Can you explain to me briefly what the problem is, and how I should manipulate the data to ensure I can produce these graphs?

          Many many thanks,
          Andreas Esbjørnsen

          Comment


          • #6
            Oops, the smiley was not intended, it was a result of a semicolon and a parenthesis :-)

            Comment


            • #7
              The problems you have include

              1. String values that have a clear order to you, but Stata cannot understand that order without being told explicitly. That applies to "before" and "after" as well as the sequence from "Never" onwards.

              2. Two variables that you want to show on a shared scale. Often that is easy to do; here it isn't easy without a different data layout.

              This code is I think equivalent to Andrew Musau's code, and perhaps a little simpler.

              Code:
              * Example generated by -dataex-. For more info, type help dataex
              clear
              input str22(strat1_before strat1_after)
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Never"                 
              "Never"                  "Less than once a month"
              "Never"                  "Less than once a month"
              "Never"                  "Once a month"          
              "Never"                  "."                     
              "Never"                  "."                     
              "Never"                  "."                     
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Less than once a month"
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "Once a month"          
              "Less than once a month" "More than once a week" 
              "Once a month"           "Never"                 
              "Once a month"           "Less than once a month"
              "Once a month"           "Less than once a month"
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a month"          
              "Once a month"           "Once a week"           
              "Once a month"           "Once a week"           
              "Once a month"           "Once a week"           
              "Once a month"           "Once a week"           
              "Once a month"           "Once a week"           
              "Once a week"            "Once a month"          
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "Once a week"           
              "Once a week"            "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              "More than once a week"  "More than once a week" 
              end
              
              * we need a different layout 
              gen long obsno=_n
              reshape long  strat1_, i(obsno) j(WHICH) string
              drop if strat1_=="."
              
              * we need before and after in conventional order 
              label def which 0 before 1 after 
              encode WHICH, gen(which) label(which)
              
              * we need to put answers in the right order 
              label def order 1 "Never" 2 "Less than once a month" 3 "Once a month" 4 "Once a week" 5 "More than once a week" 
              encode strat1_, gen(order) label(order)
              
              graph hbar (count), over(which) over(order) asyvars

              Comment


              • #8
                Dear Nick,

                Thank you so much for taking your time to help me. Unfortunately, I receive the following error code: no xij variables found r(111);

                Below I have posted another extract of my clean data without the figurations. How can I create five graphs comparing: v14+v19 & v15+v20 & v16+v21 & v17+v22 & v18+v23

                Code:
                * Example generated by -dataex-. For more info, type help dataex
                clear
                input str22(v14 v15 v16 v17 v18 v19 v20 v21 v22 v23)
                "Once a month"           "Once a week"            "Less than once a month" "Once a month"           "Once a month"           "Once a month"           "Once a month"           "Less than once a month" "Once a month"           "Once a month"          
                "Less than once a month" "Less than once a month" "Never"                  "Once a month"           "Less than once a month" "Once a month"           "Once a week"            "Less than once a month" "Once a month"           "Less than once a month"
                "Less than once a month" "More than once a week"  "Less than once a month" "Once a week"            "Once a week"            "Less than once a month" "Once a month"           "Never"                  "Once a week"            "Once a week"           
                "Less than once a month" "Once a week"            "Less than once a month" "Less than once a month" "Once a month"           "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Once a month"          
                "Less than once a month" "Once a month"           "Once a week"            "Once a month"           "Less than once a month" "Less than once a month" "Once a month"           "Once a month"           "Once a month"           "Less than once a month"
                "Once a month"           "Once a month"           "Once a week"            "Once a week"            "Once a week"            "Once a month"           "Once a week"            "Once a week"            "Once a week"            "Once a week"           
                "Never"                  "Never"                  "Never"                  "Never"                  "Less than once a month" "Never"                  "Less than once a month" "Less than once a month" "Less than once a month" "Never"                 
                "Never"                  "Less than once a month" "Never"                  "Never"                  "Never"                  "Never"                  "Less than once a month" "Never"                  "Never"                  "Never"                 
                "Never"                  "Never"                  "Once a month"           "Once a month"           "Once a month"           "Never"                  "Never"                  "Never"                  "Never"                  "Never"                 
                "Less than once a month" "Once a month"           "Once a month"           "Once a month"           "Once a month"           "Less than once a month" "Once a month"           "Once a month"           "Once a month"           "Once a month"          
                "Less than once a month" "Once a week"            "Once a month"           "Once a month"           "Less than once a month" "Once a month"           "Once a week"            "Once a month"           "Once a week"            "Once a week"           
                "Never"                  "Once a month"           "Less than once a month" "Once a month"           "Once a month"           "Never"                  "Once a month"           "Once a month"           "Once a month"           "Once a month"          
                "Once a month"           "Once a week"            "Once a week"            "More than once a week"  "More than once a week"  "Once a month"           "Once a week"            "Once a week"            "More than once a week"  "More than once a week" 
                "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month" "Less than once a month"
                end



                Thank you so much,
                Andreas Esbjørnsen
                Last edited by Andreas Esbjornsen; 25 Apr 2024, 02:57.

                Comment


                • #9
                  I can't comment on the error you got. #7 is complete code, including data, that works.

                  Otherwise the solutions you need have now been explained in detail and repeatedly. You need numeric versions of your variables after defining value labels, and indeed only a different data layout will make the graphs you want easier.



                  Last edited by Nick Cox; 25 Apr 2024, 03:52.

                  Comment

                  Working...
                  X