Hello! I have two categorical variables ("concerned_chemicals" and "concerned_bacteria") with the same label values (1="Not concerned", 2="Somewhat concerned", 3="Moderately concerned" 4="Very concerned")
I would like to create a barplot showing the counts for each label for both variables overlaid onto the same graph. On the x-axis, I would like the four variable labels, and for each label, one bar showing the counts for "concerned_chemicals" and another bar next to it showing the counts for "concerned_bacteria".
I've tried using catplot to do so, but when I use the command "catplot concerned_chemicals concerned_bacteria" or "catplot concerned_chemicals, over(concerned_bacteria)", it gives me a nested graph, which is not what I want.
thank you for any input!
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte(concerned_chemicals concerned_bacteria)
2 2
1 1
4 2
4 4
1 1
2 2
1 1
1 2
1 3
3 1
1 1
1 1
4 2
4 4
2 1
1 2
3 1
3 1
1 1
1 1
4 1
1 1
2 3
1 1
1 1
1 2
1 1
4 3
4 4
4 3
3 2
2 1
3 3
1 1
2 1
3 1
1 1
1 1
3 1
1 1
1 1
4 2
1 1
1 1
1 1
1 1
1 1
2 2
1 1
1 1
1 2
3 2
3 3
2 2
1 1
2 1
1 1
2 2
3 1
2 2
2 2
1 1
2 1
1 1
2 2
2 2
2 2
1 3
2 1
1 2
1 1
1 1
1 1
4 1
2 2
2 2
1 1
4 4
2 2
2 2
1 1
4 4
1 3
2 1
3 1
2 3
4 1
1 1
1 1
4 1
3 3
3 2
1 2
2 3
1 1
1 1
4 2
1 1
1 2
1 1
end
label values concerned_chemicals concerned
label values concerned_bacteria concerned
label def concerned 1 "Not at all concerned", modify
label def concerned 2 "Somewhat concerned", modify
label def concerned 3 "Moderately concerned", modify
label def concerned 4 "Very concerned", modify
[/CODE]
0 Response to Bar chart for two categorical variables with same value labels
Post a Comment