Hi, everyone!
I need to perform a bar graph with 2 variables containing 4 categories each.
The 2 variables are treat1 and treat2.
The categories were labeled as: 1 == "lowdose" 2 == good_treat 3 == "overdose" 4 == nd.
I want a vertical bar graph demonstrating the percentage of treat1 and treat2 for each category (lowdose, good_treat, overdose and nd).
That is, the 4 categories on x axis and each category with 2 bars (treat1 and treat2 percentages).
I'm really sorry! I've searched it on previous posts about the same issue (like "how to graph bar of categorical variables", "A simple graph bar" and "(possibly) simple bar graph comparing two variables (not one variable over the other)", but I didn't make it as I wish using those informations.
That is an example of my data:
list treat1 treat2
+---------------------+
| treat1 treat2 |
|---------------------|
1. | 1 2 |
2. | 2 4 |
3. | 2 2 |
4. | 2 2 |
5. | 4 2 |
|---------------------|
6. | 4 1 |
7. | 4 3 |
8. | 1 2 |
9. | 1 2 |
10. | 1 2 |
|---------------------|
11. | 4 1 |
12. | 3 4 |
13. | 2 4 |
14. | 4 2 |
15. | 4 4 |
|---------------------|
16. | 2 2 |
17. | 2 4 |
18. | 4 2 |
19. | 2 2 |
20. | 2 2 |
|---------------------|
21. | 2 1 |
22. | 4 2 |
23. | 4 3 |
24. | 2 1 |
25. | 1 2 |
|---------------------|
26. | 3 1 |
27. | 2 2 |
28. | 2 2 |
29. | 1 2 |
30. | 1 2 |
|---------------------|
31. | 2 2 |
32. | 2 1 |
33. | 3 4 |
34. | 2 3 |
35. | 1 2 |
|---------------------|
36. | 2 2 |
37. | 2 2 |
38. | 1 1 |
39. | 4 2 |
40. | 2 2 |
|---------------------|
41. | 2 4 |
42. | 4 2 |
43. | 4 1 |
44. | 2 3 |
45. | 2 2 |
|---------------------|
46. | 4 3 |
47. | 2 2 |
48. | 2 2 |
49. | 3 4 |
50. | 2 1 |
|---------------------|
label values treat1 origin
label def origin 1 "lowdose", modify
label def origin 2 "good_treat", modify
label def origin 3 "overdose", modify
label def origin 4 "nd", modify
label values treat2 origin
label def origin 1 "lowdose", modify
label def origin 2 "good_treat", modify
label def origin 3 "overdose", modify
label def origin 4 "nd", modify
I thank in advance for the help!
Related Posts with Bar Graph with multiples variables and categories
How to create a child number indicator?Hi all, Everyone was really helpful on my last post. Currently, I have a dataset that has parents (…
Unable to use etable command on stata 17I am attempting to use etable command documented here --> https://www.stata.com/manuals/retable.p…
New package cdfquantreg01 on SSCDear Statalisters: I have contributed this module to SSC (thanks to Kit Baum): cdfquantreg01: Stata …
How to add average treatment effect line in event study plotDear community, I want to add the average treatment effect (and confidence interval) when plotting …
New package: rowsumHi Everyone, I write a new package called "rowsum" (my first package : ). It sums the values of mul…
Subscribe to:
Post Comments (Atom)
0 Response to Bar Graph with multiples variables and categories
Post a Comment