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
Value weighted returns are the same as equal weighted returnsDear everyone, Im sorry to post something similar as my post yesterday, however it is really importa…
How to export unit root test results to excel?Hello, We have estout/esttab, outreg2 commands to exports regression output. Is it possible to expor…
Merger of datasets with different data frequencyHi everyone, I have to merge two datasets: "Monthly data" and "Fundamentals quarterly". The first …
Testing for autocorrelation in a logistic regression analysis with panel dataI am trying scrutinize the relationship between regimetypes (political regimes eg. closed autocracy,…
Replacing with lagged value.Dear All, I have population data by age brackets(7 age categories *agecats* : 0-14, 15-24, 25-34, 3…
Subscribe to:
Post Comments (Atom)
0 Response to Graphing two categorical variables
Post a Comment