Announcement

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

  • bar graph for countries with horizontal lines for region means

    Hello. I have a cross section of health spending per country (in 7 different regions) for the year of 2018. I created a variable with the average of health spending per region using the egen command.

    I would like to have a graph with the ranking of health spending per country as bars and the means of the 7 different regions as horizontal lines. Is it possible to do so?

    Many thanks,
    Paula

  • #2
    To answer your question: Yes, it is possible to do so.

    To anticipate the likely follow up question: How you do that depends on the exact data structure. If you can give us an example of your data, then we can build example code that is useful to you. See help dataex
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Many thanks! This command is super helpful.

      Please find below the structure of my data:

      Code:
      clear
      input str48 country float cat_reg int percap_total float percap_total_reg byte Selection int year
      "United States"          5 9839      7380 1 2015
      "Andorra"                2 9203  2798.714 0 2015
      "Switzerland"            2 7465  2798.714 1 2015
      "Norway"                 2 7024  2798.714 1 2015
      "Luxembourg"             2 6530  2798.714 1 2015
      "Netherlands"            2 5579  2798.714 1 2015
      "Sweden"                 2 5550  2798.714 1 2015
      "Germany"                2 5532  2798.714 1 2015
      "Ireland"                2 5371  2798.714 1 2015
      "Austria"                2 5183  2798.714 1 2015
      "Denmark"                2 5144  2798.714 1 2015
      "Belgium"                2 4939  2798.714 1 2015
      "Canada"                 5 4921      7380 1 2015
      "France"                 2 4741  2798.714 1 2015
      "Australia"              1 4400 1098.6072 1 2015
      "Japan"                  1 4286 1098.6072 1 2015
      "United Kingdom"         2 4285  2798.714 1 2015
      "Iceland"                2 4205  2798.714 1 2015
      "Finland"                2 4101  2798.714 1 2015
      "Singapore"              1 3657 1098.6072 0 2015
      "New Zealand"            1 3648 1098.6072 1 2015
      "Malta"                  4 3642 1419.9524 0 2015
      "Italy"                  2 3445  2798.714 1 2015
      "Spain"                  2 3363  2798.714 1 2015
      "Qatar"                  4 3251 1419.9524 0 2015
      "Saudi Arabia"           4 3138 1419.9524 0 2015
      "South Korea"            1 2835 1098.6072 1 2015
      "Cyprus"                 2 2821  2798.714 0 2015
      "Slovenia"               2 2806  2798.714 1 2015
      "Portugal"               2 2712  2798.714 1 2015
      "Kuwait"                 4 2640 1419.9524 0 2015
      "Israel"                 4 2560 1419.9524 1 2015
      "Taiwan"                 1 2535 1098.6072 0 2015
      "Czech Republic"         2 2534  2798.714 1 2015
      "United Arab Emirates"   4 2489 1419.9524 0 2015
      "Bahrain"                4 2470 1419.9524 0 2015
      "Greece"                 2 2352  2798.714 1 2015
      "Slovakia"               2 2216  2798.714 1 2015
      "Brunei"                 1 2092 1098.6072 0 2015
      "Uruguay"                3 2038  948.9063 1 2015
      "Hungary"                2 2031  2798.714 1 2015
      "Trinidad and Tobago"    3 2024  948.9063 0 2015
      "Chile"                  3 1950  948.9063 1 2015
      "Estonia"                2 1946  2798.714 1 2015
      "Lithuania"              2 1941  2798.714 0 2015
      "Maldives"               6 1850   411.375 0 2015
      "The Bahamas"            3 1818  948.9063 0 2015
      "Poland"                 2 1757  2798.714 1 2015
      "Croatia"                2 1736  2798.714 0 2015
      "Oman"                   4 1684 1419.9524 0 2015
      "Latvia"                 2 1683  2798.714 1 2015
      "Bulgaria"               2 1620  2798.714 0 2015
      "Panama"                 3 1588  948.9063 1 2015
      "Russian Federation"     2 1544  2798.714 0 2015
      "Argentina"              3 1457  948.9063 1 2015
      "Brazil"                 3 1431  948.9063 1 2015
      "Serbia"                 2 1398  2798.714 0 2015
      "Costa Rica"             3 1339  948.9063 1 2015
      "Barbados"               3 1237  948.9063 0 2015
      "Iran"                   4 1232 1419.9524 0 2015
      "Belarus"                2 1232  2798.714 0 2015
      "Azerbaijan"             2 1221  2798.714 0 2015
      "Lebanon"                4 1207 1419.9524 0 2015
      "Antigua and Barbuda"    3 1198  948.9063 0 2015
      "Turkmenistan"           2 1171  2798.714 0 2015
      "Romania"                2 1128  2798.714 0 2015
      "South Africa"           7 1109 282.41666 0 2015
      "Mauritius"              7 1094 282.41666 0 2015
      "Equatorial Guinea"      7 1089 282.41666 0 2015
      "Mexico"                 3 1081  948.9063 1 2015
      "Bosnia and Herzegovina" 2 1076  2798.714 0 2015
      "Malaysia"               1 1072 1098.6072 0 2015
      "Namibia"                7 1033 282.41666 0 2015
      "Turkey"                 2 1029  2798.714 1 2015
      "Ecuador"                3 1028  948.9063 1 2015
      "Algeria"                4 1026 1419.9524 0 2015
      "Botswana"               7 1019 282.41666 0 2015
      "Kazakhstan"             2 1017  2798.714 0 2015
      "Suriname"               3  993  948.9063 0 2015
      "Montenegro"             2  985  2798.714 0 2015
      "Cuba"                   3  977  948.9063 0 2015
      "Seychelles"             7  957 282.41666 0 2015
      "Dominican Republic"     3  932  948.9063 0 2015
      "Macedonia"              2  921  2798.714 0 2015
      "Colombia"               3  861  948.9063 1 2015
      "Armenia"                2  849  2798.714 0 2015
      "Albania"                2  848  2798.714 0 2015
      "Georgia"                2  803  2798.714 0 2015
      "Tunisia"                4  791 1419.9524 0 2015
      "China"                  1  779 1098.6072 0 2015
      "Paraguay"               3  738  948.9063 1 2015
      "Jordan"                 4  730 1419.9524 0 2015
      "Grenada"                3  715  948.9063 0 2015
      "Saint Lucia"            3  714  948.9063 0 2015
      "Swaziland"              7  693 282.41666 0 2015
      "Peru"                   3  683  948.9063 1 2015
      "Thailand"               1  614 1098.6072 0 2015
      "Dominica"               3  606  948.9063 0 2015
      "Marshall Islands"       1  604 1098.6072 0 2015
      "Ukraine"                2  598  2798.714 0 2015
      end
      label values cat_reg cat_reg
      label def cat_reg 1 "East Asia and Pacific", modify
      label def cat_reg 2 "Europe and Central Asia", modify
      label def cat_reg 3 "Latin America and the Caribbean", modify
      label def cat_reg 4 "Middle East and North Africa", modify
      label def cat_reg 5 "North America", modify
      label def cat_reg 6 "South Asia", modify
      label def cat_reg 7 "Sub-Saharan Africa", modify
      
      label var cat_reg "classification of country by region"
      label var Selection "selection of countries for the graph"
      label var percap_total "Total Health Spending per Capita (thousands of 2017 US$, PPP)"
      label var percap_total_reg "Total Health Spending per Capita by Region (thousands of 2017 US$, PPP)"
      I wish to have a graph with information of health spending for all countries for which the dummy variable named Selection is equal to 0 as well as the means for the regions. I can either have the means of the regions as bars as well (as if regions where other countries) or as horizontal lines.

      I did manage to run the graph at the country level (highlighting Brazil) and another graph at the region level (codes below) but I did not manage to combine them with the command twoway. Could someone please help me out with this?

      code for the country level graph
      Code:
      separate percap_total, by(country == "Brazil")
      
      graph bar percap_total0 percap_total1 if year==2015 & Selection==1, ///
      over(country, label(angle(90) labsize(vsmall)) sort(percap_total) descending) ///
      ytitle("") yscale(off) blabel(total, orientation(vertical) size(vsmall)) legend(off) nofill ///
      bar(2, bcolor(red))
      code for the regional level graph
      Code:
      graph bar (mean) percap_total_reg if year==2015, ///
      over(cat_reg, label(angle(90) labsize(vsmall)) sort(percap_total) descending) ///
      ytitle("") yscale(off) blabel(total, orientation(vertical) size(vsmall)) legend(off)

      Comment


      • #4
        To add several different lines I think you'd have to shift the whole graph to twoway as in essence graph bar and graph twoway can't be mixed.

        Is it needed any way? I played with your data and grouped by regions, which easily allows an assessment of typical level. This graph could be further improved e.g. by putting the region labels on two lines each, not one.

        NB with my default graph scheme (s1color) the colors are too close to green and red. Something else to fix.

        Code:
        clear
        input str48 country float cat_reg int percap_total float percap_total_reg byte Selection int year
        "United States"          5 9839      7380 1 2015
        "Andorra"                2 9203  2798.714 0 2015
        "Switzerland"            2 7465  2798.714 1 2015
        "Norway"                 2 7024  2798.714 1 2015
        "Luxembourg"             2 6530  2798.714 1 2015
        "Netherlands"            2 5579  2798.714 1 2015
        "Sweden"                 2 5550  2798.714 1 2015
        "Germany"                2 5532  2798.714 1 2015
        "Ireland"                2 5371  2798.714 1 2015
        "Austria"                2 5183  2798.714 1 2015
        "Denmark"                2 5144  2798.714 1 2015
        "Belgium"                2 4939  2798.714 1 2015
        "Canada"                 5 4921      7380 1 2015
        "France"                 2 4741  2798.714 1 2015
        "Australia"              1 4400 1098.6072 1 2015
        "Japan"                  1 4286 1098.6072 1 2015
        "United Kingdom"         2 4285  2798.714 1 2015
        "Iceland"                2 4205  2798.714 1 2015
        "Finland"                2 4101  2798.714 1 2015
        "Singapore"              1 3657 1098.6072 0 2015
        "New Zealand"            1 3648 1098.6072 1 2015
        "Malta"                  4 3642 1419.9524 0 2015
        "Italy"                  2 3445  2798.714 1 2015
        "Spain"                  2 3363  2798.714 1 2015
        "Qatar"                  4 3251 1419.9524 0 2015
        "Saudi Arabia"           4 3138 1419.9524 0 2015
        "South Korea"            1 2835 1098.6072 1 2015
        "Cyprus"                 2 2821  2798.714 0 2015
        "Slovenia"               2 2806  2798.714 1 2015
        "Portugal"               2 2712  2798.714 1 2015
        "Kuwait"                 4 2640 1419.9524 0 2015
        "Israel"                 4 2560 1419.9524 1 2015
        "Taiwan"                 1 2535 1098.6072 0 2015
        "Czech Republic"         2 2534  2798.714 1 2015
        "United Arab Emirates"   4 2489 1419.9524 0 2015
        "Bahrain"                4 2470 1419.9524 0 2015
        "Greece"                 2 2352  2798.714 1 2015
        "Slovakia"               2 2216  2798.714 1 2015
        "Brunei"                 1 2092 1098.6072 0 2015
        "Uruguay"                3 2038  948.9063 1 2015
        "Hungary"                2 2031  2798.714 1 2015
        "Trinidad and Tobago"    3 2024  948.9063 0 2015
        "Chile"                  3 1950  948.9063 1 2015
        "Estonia"                2 1946  2798.714 1 2015
        "Lithuania"              2 1941  2798.714 0 2015
        "Maldives"               6 1850   411.375 0 2015
        "The Bahamas"            3 1818  948.9063 0 2015
        "Poland"                 2 1757  2798.714 1 2015
        "Croatia"                2 1736  2798.714 0 2015
        "Oman"                   4 1684 1419.9524 0 2015
        "Latvia"                 2 1683  2798.714 1 2015
        "Bulgaria"               2 1620  2798.714 0 2015
        "Panama"                 3 1588  948.9063 1 2015
        "Russian Federation"     2 1544  2798.714 0 2015
        "Argentina"              3 1457  948.9063 1 2015
        "Brazil"                 3 1431  948.9063 1 2015
        "Serbia"                 2 1398  2798.714 0 2015
        "Costa Rica"             3 1339  948.9063 1 2015
        "Barbados"               3 1237  948.9063 0 2015
        "Iran"                   4 1232 1419.9524 0 2015
        "Belarus"                2 1232  2798.714 0 2015
        "Azerbaijan"             2 1221  2798.714 0 2015
        "Lebanon"                4 1207 1419.9524 0 2015
        "Antigua and Barbuda"    3 1198  948.9063 0 2015
        "Turkmenistan"           2 1171  2798.714 0 2015
        "Romania"                2 1128  2798.714 0 2015
        "South Africa"           7 1109 282.41666 0 2015
        "Mauritius"              7 1094 282.41666 0 2015
        "Equatorial Guinea"      7 1089 282.41666 0 2015
        "Mexico"                 3 1081  948.9063 1 2015
        "Bosnia and Herzegovina" 2 1076  2798.714 0 2015
        "Malaysia"               1 1072 1098.6072 0 2015
        "Namibia"                7 1033 282.41666 0 2015
        "Turkey"                 2 1029  2798.714 1 2015
        "Ecuador"                3 1028  948.9063 1 2015
        "Algeria"                4 1026 1419.9524 0 2015
        "Botswana"               7 1019 282.41666 0 2015
        "Kazakhstan"             2 1017  2798.714 0 2015
        "Suriname"               3  993  948.9063 0 2015
        "Montenegro"             2  985  2798.714 0 2015
        "Cuba"                   3  977  948.9063 0 2015
        "Seychelles"             7  957 282.41666 0 2015
        "Dominican Republic"     3  932  948.9063 0 2015
        "Macedonia"              2  921  2798.714 0 2015
        "Colombia"               3  861  948.9063 1 2015
        "Armenia"                2  849  2798.714 0 2015
        "Albania"                2  848  2798.714 0 2015
        "Georgia"                2  803  2798.714 0 2015
        "Tunisia"                4  791 1419.9524 0 2015
        "China"                  1  779 1098.6072 0 2015
        "Paraguay"               3  738  948.9063 1 2015
        "Jordan"                 4  730 1419.9524 0 2015
        "Grenada"                3  715  948.9063 0 2015
        "Saint Lucia"            3  714  948.9063 0 2015
        "Swaziland"              7  693 282.41666 0 2015
        "Peru"                   3  683  948.9063 1 2015
        "Thailand"               1  614 1098.6072 0 2015
        "Dominica"               3  606  948.9063 0 2015
        "Marshall Islands"       1  604 1098.6072 0 2015
        "Ukraine"                2  598  2798.714 0 2015
        end
        label values cat_reg cat_reg
        label def cat_reg 1 "East Asia and Pacific", modify
        label def cat_reg 2 "Europe and Central Asia", modify
        label def cat_reg 3 "Latin America and the Caribbean", modify
        label def cat_reg 4 "Middle East and North Africa", modify
        label def cat_reg 5 "North America", modify
        label def cat_reg 6 "South Asia", modify
        label def cat_reg 7 "Sub-Saharan Africa", modify
        
        label var cat_reg "classification of country by region"
        label var Selection "selection of countries for the graph"
        label var percap_total "Total Health Spending per Capita (thousands of 2017 US$, PPP)"
        label var percap_total_reg "Total Health Spending per Capita by Region (thousands of 2017 US$, PPP)"
        
        separate percap_total, by(country == "Brazil")
        
        graph hbar percap_total0 percap_total1 if year==2015 & Selection==1, ///
        over(country, label(labsize(vsmall)) sort(percap_total) descending) ///
        over(cat_reg, label(labsize(small)) sort(percap_total) descending) ///
        ytitle("") yscale(off) blabel(total, size(vsmall)) legend(off) nofill ///
        bar(2, bcolor(red)) name(Paula1, replace) ysc(r(0 10500)) aspect(2)
        Click image for larger version

Name:	Paula1.png
Views:	1
Size:	35.9 KB
ID:	1446413

        Comment


        • #5
          Many thanks Nick. Unfortunately this does not solve my problem. I would like to show only some selected countries in the graph bar (this is why I created the dummy variable named Selection). However I would like to show the average of all regions in the world to make it comparable. Those averages are computed in the variable percap_total_reg. Ideally, I would like to have them as bars in a different color as if they were other countries. Is it possible?


          Comment


          • #6
            Sure. Rewrite your code in terms of twoway bar.

            Comment


            • #7
              I am trying to do so, but I am having some trouble because most of the options which I used above are not allowed for the twoway command (e.g. over(), blabel(), nofill, etc)

              How can I have the xlabel as string?
              How can I have it all in a descending order?
              How can I have the data values in the columns?

              Code:
              clear
              input long country_id str48 country float cat_reg int percap_total float percap_total_reg byte Selection int year
              102 "United States"          5 9839      7380 1 2015
               74 "Andorra"                2 9203  2798.714 0 2015
               94 "Switzerland"            2 7465  2798.714 1 2015
               90 "Norway"                 2 7024  2798.714 1 2015
               87 "Luxembourg"             2 6530  2798.714 1 2015
               89 "Netherlands"            2 5579  2798.714 1 2015
               93 "Sweden"                 2 5550  2798.714 1 2015
               81 "Germany"                2 5532  2798.714 1 2015
               84 "Ireland"                2 5371  2798.714 1 2015
               75 "Austria"                2 5183  2798.714 1 2015
               78 "Denmark"                2 5144  2798.714 1 2015
               76 "Belgium"                2 4939  2798.714 1 2015
              101 "Canada"                 5 4921      7380 1 2015
               80 "France"                 2 4741  2798.714 1 2015
               71 "Australia"              1 4400 1098.6072 1 2015
               67 "Japan"                  1 4286 1098.6072 1 2015
               95 "United Kingdom"         2 4285  2798.714 1 2015
               83 "Iceland"                2 4205  2798.714 1 2015
               79 "Finland"                2 4101  2798.714 1 2015
               69 "Singapore"              1 3657 1098.6072 0 2015
               72 "New Zealand"            1 3648 1098.6072 1 2015
               88 "Malta"                  4 3642 1419.9524 0 2015
               86 "Italy"                  2 3445  2798.714 1 2015
               92 "Spain"                  2 3363  2798.714 1 2015
              151 "Qatar"                  4 3251 1419.9524 0 2015
              152 "Saudi Arabia"           4 3138 1419.9524 0 2015
               68 "South Korea"            1 2835 1098.6072 1 2015
               77 "Cyprus"                 2 2821  2798.714 0 2015
               55 "Slovenia"               2 2806  2798.714 1 2015
               91 "Portugal"               2 2712  2798.714 1 2015
              145 "Kuwait"                 4 2640 1419.9524 0 2015
               85 "Israel"                 4 2560 1419.9524 1 2015
                8 "Taiwan"                 1 2535 1098.6072 0 2015
               47 "Czech Republic"         2 2534  2798.714 1 2015
              156 "United Arab Emirates"   4 2489 1419.9524 0 2015
              140 "Bahrain"                4 2470 1419.9524 0 2015
               82 "Greece"                 2 2352  2798.714 1 2015
               54 "Slovakia"               2 2216  2798.714 1 2015
               66 "Brunei"                 1 2092 1098.6072 0 2015
               99 "Uruguay"                3 2038  948.9063 1 2015
               48 "Hungary"                2 2031  2798.714 1 2015
              119 "Trinidad and Tobago"    3 2024  948.9063 0 2015
               98 "Chile"                  3 1950  948.9063 1 2015
               58 "Estonia"                2 1946  2798.714 1 2015
               60 "Lithuania"              2 1941  2798.714 0 2015
               14 "Maldives"               6 1850   411.375 0 2015
              106 "The Bahamas"            3 1818  948.9063 0 2015
               51 "Poland"                 2 1757  2798.714 1 2015
               46 "Croatia"                2 1736  2798.714 0 2015
              150 "Oman"                   4 1684 1419.9524 0 2015
               59 "Latvia"                 2 1683  2798.714 1 2015
               45 "Bulgaria"               2 1620  2798.714 0 2015
              132 "Panama"                 3 1588  948.9063 1 2015
               62 "Russian Federation"     2 1544  2798.714 0 2015
               97 "Argentina"              3 1457  948.9063 1 2015
              135 "Brazil"                 3 1431  948.9063 1 2015
               53 "Serbia"                 2 1398  2798.714 0 2015
              126 "Costa Rica"             3 1339  948.9063 1 2015
              107 "Barbados"               3 1237  948.9063 0 2015
               57 "Belarus"                2 1232  2798.714 0 2015
              142 "Iran"                   4 1232 1419.9524 0 2015
               34 "Azerbaijan"             2 1221  2798.714 0 2015
              146 "Lebanon"                4 1207 1419.9524 0 2015
              105 "Antigua and Barbuda"    3 1198  948.9063 0 2015
               40 "Turkmenistan"           2 1171  2798.714 0 2015
               52 "Romania"                2 1128  2798.714 0 2015
              196 "South Africa"           7 1109 282.41666 0 2015
              183 "Mauritius"              7 1094 282.41666 0 2015
              172 "Equatorial Guinea"      7 1089 282.41666 0 2015
              130 "Mexico"                 3 1081  948.9063 1 2015
               44 "Bosnia and Herzegovina" 2 1076  2798.714 0 2015
               13 "Malaysia"               1 1072 1098.6072 0 2015
              195 "Namibia"                7 1033 282.41666 0 2015
              155 "Turkey"                 2 1029  2798.714 1 2015
              122 "Ecuador"                3 1028  948.9063 1 2015
              139 "Algeria"                4 1026 1419.9524 0 2015
              193 "Botswana"               7 1019 282.41666 0 2015
               36 "Kazakhstan"             2 1017  2798.714 0 2015
              118 "Suriname"               3  993  948.9063 0 2015
               50 "Montenegro"             2  985  2798.714 0 2015
              109 "Cuba"                   3  977  948.9063 0 2015
              186 "Seychelles"             7  957 282.41666 0 2015
              111 "Dominican Republic"     3  932  948.9063 0 2015
               49 "Macedonia"              2  921  2798.714 0 2015
              125 "Colombia"               3  861  948.9063 1 2015
               33 "Armenia"                2  849  2798.714 0 2015
               43 "Albania"                2  848  2798.714 0 2015
               35 "Georgia"                2  803  2798.714 0 2015
              154 "Tunisia"                4  791 1419.9524 0 2015
                6 "China"                  1  779 1098.6072 0 2015
              136 "Paraguay"               3  738  948.9063 1 2015
              144 "Jordan"                 4  730 1419.9524 0 2015
              112 "Grenada"                3  715  948.9063 0 2015
              116 "Saint Lucia"            3  714  948.9063 0 2015
              197 "Swaziland"              7  693 282.41666 0 2015
              123 "Peru"                   3  683  948.9063 1 2015
               18 "Thailand"               1  614 1098.6072 0 2015
              110 "Dominica"               3  606  948.9063 0 2015
               24 "Marshall Islands"       1  604 1098.6072 0 2015
              127 "El Salvador"            3  598  948.9063 1 2015
              end
              label values cat_reg cat_reg
              label def cat_reg 1 "East Asia and Pacific", modify
              label def cat_reg 2 "Europe and Central Asia", modify
              label def cat_reg 3 "Latin America and the Caribbean", modify
              label def cat_reg 4 "Middle East and North Africa", modify
              label def cat_reg 5 "North America", modify
              label def cat_reg 6 "South Asia", modify
              label def cat_reg 7 "Sub-Saharan Africa", modify
              
              label var cat_reg "classification of country by region"
              label var Selection "selection of countries for the graph"
              label var percap_total "Total Health Spending per Capita (thousands of 2017 US$, PPP)"
              label var percap_total_reg "Total Health Spending per Capita by Region (thousands of 2017 US$, PPP)"
              
              * highlighting Brazil in the graph
              separate percap_total, by(country == "Brazil")
              
              twoway bar percap_total_reg cat_reg if year==2015, ///
              ytitle("") yscale(off) legend(off) || ///
              bar percap_total0 percap_total1 country_id if year==2015 & Selection==1, ///
              ytitle("") yscale(off) legend(off)

              All I would like to do is to combine those two graph bars into a single graph, having the columns in descending order
              Code:
              * country level
              graph bar percap_total0 percap_total1 if year==2015 & Selection==1, ///
              over(country, label(angle(90) labsize(vsmall)) sort(percap_total) descending) ///
              ytitle("") yscale(off) blabel(total, orientation(vertical) size(vsmall)) legend(off) nofill ///
              bar(2, bcolor(red))
              
              * category level
              graph bar (mean) percap_total_reg if year==2015, ///
              over(cat_reg, label(angle(90) labsize(vsmall)) sort(percap_total_reg) descending) ///
              ytitle("") yscale(off) blabel(total, orientation(vertical) size(vsmall)) legend(off) 
              
              * combining grafs (did not work)
              twoway bar percap_total_reg if year==2015, ///
              over(cat_reg, label(angle(90) labsize(vsmall)) sort(percap_total) descending) ///
              ytitle("") yscale(off) blabel(total, orientation(vertical) size(vsmall)) legend(off) || ///
              bar percap_total0 percap_total1 if year==2015 & Selection==1, ///
              over(country, label(angle(90) labsize(vsmall)) sort(percap_total_reg) descending) ///
              ytitle("") yscale(off) blabel(total, orientation(vertical) size(vsmall)) legend(off) nofill ///
              bar(2, bcolor(red))

              Comment


              • #8
                Some hints within https://www.stata-journal.com/sjpdf....iclenum=gr0034

                Sorry, but the goal doesn't interest me enough for me to give further time to this question.

                Comment


                • #9
                  P.S I found my answer. Thanx
                  Last edited by bibha dhungel; 03 Feb 2021, 02:25.

                  Comment

                  Working...
                  X