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 do I regress by month?My panel of data looks like the sample below. I am trying to regress 'subs' with the remaining varia…
an error occurred when svy executed mlogit: option baseoutcome() is required with prefix svy bootstrapHi, Using the code below, I am trying to obtain and save marginal estimates for each iteration of my…
Multiple sheets export excelHello, I want to export the "auto" file in several Excel's sheets (one per brand). Code: sysuse aut…
New package: Relogitplot - predictive margins plots after relogit regressionsIf you use the relogit package (Tomz, King, and Zeng), you may be interested in an addon I wrote whi…
Testing the equality of the regression coefficientsThe main regression model reghdfe y x controls, absorb (ind fyear) vce(cluster gvkey) Now I want t…
Subscribe to:
Post Comments (Atom)
0 Response to Bar Graph with multiples variables and categories
Post a Comment