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
create a table with two "variable-groups" as x- and y-axis and the corresponding returns for each combinationHello I am trying to recreate table1, panel A from Fama & French (2015), which looks as follows…
Problem with running a DO file in STATA SE 16 for Mac IOSDear colleagues, I want your help please, I received a Do file from windows STATA version, and i am …
svy Stata 16: how to get value labels e(label1) or e(over_labels)Dear Stata users, I need to save the value labels after estimation using svy mean or svy mean ..., …
Fill missing values by groupsHi there, I have read quite some posts on the topic but I don't seem to find a solution. Please con…
Testing revenue convergence hypothesisHi, I would like to replicate the convergece test Dobson, Goddard and Ramlogan use in the article R…
Subscribe to:
Post Comments (Atom)
0 Response to Bar chart for two categorical variables with same value labels
Post a Comment