Hi All,
I want to create a graph that shows within each combination of race and gender what percentage of subjects responded "Totally Untrue," "Mostly Untrue," or "Somewhat" (i.e., option 1, 2, or 3) to item1. Thus, it is theoretically possible that each bar could reach 100% on its own, if, for example, if all white females responded 1, 2, or 3, to item1 that bar would reach 100% on the graph.
Here is the code I used to create a dataset that mimics my real dataset, as well as the code I used to create the graph:
This is the graph I get:

Which looks exactly how I want it to, but the percentages don't seem to represent what I want them to represent. It seems that the graph is showing what percentage of the larger group of subjects who responded "Totally Untrue," "Mostly Untrue," or "Somewhat" are White females, etc.
Previously, I had tried to create an indicator variable denoting whether a respondent was below 4 on item1, something like:
But I couldn't find a way to create a graph to my liking using this variable.
I'm pretty sure I'm missing something obvious, but I've been in the weeds on this for a while and thought I could use a fresh (and highly qualified) perspective.
Thanks in advance!
-Jake
I want to create a graph that shows within each combination of race and gender what percentage of subjects responded "Totally Untrue," "Mostly Untrue," or "Somewhat" (i.e., option 1, 2, or 3) to item1. Thus, it is theoretically possible that each bar could reach 100% on its own, if, for example, if all white females responded 1, 2, or 3, to item1 that bar would reach 100% on the graph.
Here is the code I used to create a dataset that mimics my real dataset, as well as the code I used to create the graph:
Code:
clear set seed 123456 set obs 2000 gen item1 = int(uniform() * 5) + 1 gen male = int(uniform() * 2) gen race = int(uniform() * 4) + 1 label var item1 "I love science." label define anslblitem1 1 "Totally Untrue" 2 "Mostly Untrue" 3 "Somewhat" /// 4 "Mostly True" 5 "Totally True" label values item1 anslblitem1 label define racelbl 1 "White" 2 "Black" 3 "Hispanic" 4 "Asian" label values race racelbl label define malelbl 1 "Males" 0 "Females" label values male malelbl graph bar if item1 < 4 & item1!=., over(male) over(race) asyvars
Which looks exactly how I want it to, but the percentages don't seem to represent what I want them to represent. It seems that the graph is showing what percentage of the larger group of subjects who responded "Totally Untrue," "Mostly Untrue," or "Somewhat" are White females, etc.
Previously, I had tried to create an indicator variable denoting whether a respondent was below 4 on item1, something like:
Code:
gen item1_low = 1 if item1 < 4 & item1!=.
I'm pretty sure I'm missing something obvious, but I've been in the weeds on this for a while and thought I could use a fresh (and highly qualified) perspective.
Thanks in advance!
-Jake
Comment