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
Fan Chart (line chart + area)I'm trying to replicate a fan chart which shows a line along with +/- 1 and 2 standard errors. For c…
dcreate (efficient designs / choice experiments)Dear friends: I am working with the dcreate command to build efficient designs for choice experiment…
Help with ado file created command optionsHello Statalist Users, I have two general questions about creating commands in Ado files. I am just…
Create polygon using coordinatesDoes stata have the capability to help create a shape file by filling in the lines between coordinat…
2 way tabulation - adding percentages only to the final row and column of the tableHi everyone, I have got a problem, wherein I need to do a 2 way tabulation for example, for the gen…
Subscribe to:
Post Comments (Atom)
0 Response to Graphing two categorical variables
Post a Comment