Hi everyone,
I want to display the frequencies of one categorical variable (attitude) over the categories of another (country) in a stacked bar chart. The attitude variable has 5 (Likert scale) categories. I have two specific aims, which I do not know how to accomplish using Stata:
But slideplot cannot sort the bars. Also, you either have to chose whether the middle category 3 goes to the left or to the right, or you have to leave it out completely.
With graph hbar I can at least sort the stacked bars according to one of the categories, but I still cannot center them around their middle category.
Does anyone have a suggestion of how to do this? Any help is much appreciated!
Kind regards,
Uwe
I produced a tiny example dataset in case you need it:
I want to display the frequencies of one categorical variable (attitude) over the categories of another (country) in a stacked bar chart. The attitude variable has 5 (Likert scale) categories. I have two specific aims, which I do not know how to accomplish using Stata:
- The middle or neutral category of the attitude variable should be at the center of the graph over all the countries.
- The stacked bars should be sorted according to the frequency of one (or more) categories of the attitude variable.
- Figure 2 of this article http://www.amstat.org/sections/srms/...0784_64164.pdf by Naomi B. Robbins and Richard M. Heiberger (2011): Plotting Likert and Other Rating Scales
- The first image under the section "Diverging Stacked Bar Charts" on this website: http://peltiertech.com/charting-survey-results/
Code:
slideplot hbar attitude , by(country) percent neg(1 2 3) pos(4 5)
Code:
tab attitude, gen(attitudeCat) graph hbar attitudeCat1 attitudeCat2 attitudeCat3 attitudeCat4 attitudeCat5 /// , percent stack over(country, sort(5) descending)
Does anyone have a suggestion of how to do this? Any help is much appreciated!
Kind regards,
Uwe
I produced a tiny example dataset in case you need it:
Code:
clear input float attitude long country 4 2 4 2 5 2 4 2 5 2 2 2 5 2 4 2 5 2 4 2 5 2 1 2 1 2 1 2 .c 2 5 3 3 3 2 3 4 3 4 3 5 3 .c 3 5 3 5 3 5 3 4 3 1 3 1 3 1 3 1 3 .c 4 3 4 4 4 5 4 3 4 5 4 4 4 4 4 5 4 4 4 .c 4 5 5 5 5 3 5 5 5 4 5 3 5 4 5 2 5 4 5 5 5 4 5 5 5 2 5 4 5 4 5 5 5 4 5 5 5 3 5 5 5 4 5 .c 5 1 6 4 6 5 6 4 6 3 6 4 6 4 6 5 6 4 6 2 6 4 6 4 6 2 6 1 6 5 6 2 6 2 6 5 6 4 6 4 6 4 6 4 7 4 7 5 7 1 7 4 7 3 7 4 7 5 7 1 7 1 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 5 7 4 7 5 7 2 7 4 7 end label values country country label def country 2 "A", modify label def country 3 "B", modify label def country 4 "C", modify label def country 5 "D", modify label def country 6 "E", modify label def country 7 "F", modify
Comment