Hello everyone,
I'm new to the Forum and relatively beginner at Stata, so sorry if the answer for what I am looking for is too obvious. I need to create a bar chart of two categorical variables: one is Subject (Math or History) and other is Type (A, B, C, or D). My data is structured as follows (example):
Subject Type
Math A
Hist A
Hist B
Math C
Hist C
Hist C
Hist D
Hist A
Hist A
Math A
Math A
Math A
Math C
Math C
Hist D
Math D
Math A
I'm looking for a command that will visually give me the percentage of each type, by subject, in one single graph. I'm looking for something like this:
Array
If I do graph bar, over(Type) over(Subject), not only I end up with two graphs, one for each subject, but also Stata does not separately calculate the percentage for each Subject (in my database I have many more Math observations than History):
Array
Using graph bar, over(Type) by(Subject) Stata gives me the relative proportions, but still in two graphs:
Array
Any ideas of how to get what I need? Thanks!
Related Posts with Graphing two categorical variables
Recode returns incorrect codeI am try to execute the following code Code: recode educn (1=0)(2/4=1)(5=3)(6=5)(12=15)(10=12)(8=1…
Unable to refer to sreturned varlist outside of programI wrote an sclass program which returns two variable lists in separate macros: Code: capture prog…
Loop Through The Same Procedures with Multiple DatasetsHi all, I have several datasets that I would like to do the same procedures to. I have the same gen…
Any alternative to svy: bsqreg ? [Since svy does not support bsqreg]I was wondering if there are any alternatives to using svyset since bsqreg does not support svy and …
String variable to date formatHi, I am encountered with a problem in converting a string variable to date format to enable time s…
Subscribe to:
Post Comments (Atom)
0 Response to Graphing two categorical variables
Post a Comment