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]
Related Posts with Bar chart for two categorical variables with same value labels
poisson regression resultpoisson regression result Today, 02:13 i am doing research on determinants of crop diversity and po…
Short panel, random-effects model with heteroskedasticity, autocorrelation and cross sectional independence problemsHi everyone, I'm working with a short panel (N=95, T=6). I have carried out the robust Hausman test …
simple stacked bar with two different continous variables on x axisHello and happy Good Friday I'm trying to reproduce in STATA a following stacked bar chart (done i…
How do I reformat data from excel in bulk while importing?Hi, I'm fairly new to Stata, so this question may be somewhat basic I need to import a decent amou…
Multiple Imputation - How to compute restrictions for the imputation?Dear all, I think my problem should be easy to solve, but I just cannot figure it out, so I hope so…
Subscribe to:
Post Comments (Atom)
0 Response to Bar chart for two categorical variables with same value labels
Post a Comment