Hi everyone, I've searched the manuals and forums here for an answer but to no avail. I was hoping there's someone who could answer my question:
I created a bar graph to display the percentages of all values of a categorical variable (lets call it accident_type). accident_type contains 20 different values (disease, burns, violence, etc...) and I stratified accident_type over years 2010-2015. I used the following code:
graph bar, over(accident_type) over(years)
*note I had to use over(accident_type) because it's a string variable and the graph wouldn't let me use time-series operators, luckily over() fixes this problem
But as you can imagine, displaying 20 values and stratified over 6 years over a bar graph can be quite squished and hard to read so I wanted to display only the value "violence" in accident_type. I used the following code:
graph bar if accident_type=="violence", over(accident_type) over(years)
However, this code recalculates the percentage of "violence" as if now I've created a subpopulation where I restricted the dataset to look only at those with "violence" in accident_type. For example, in the first graph "violence" in 2010 was perhaps 5%, and in the second graph "violence" in 2010 is now 25%. I didn't want to restrict the population and recalculate the proportions; I only wanted to restrict the graph to only show "violence". Is there a way to do this?
I created a bar graph to display the percentages of all values of a categorical variable (lets call it accident_type). accident_type contains 20 different values (disease, burns, violence, etc...) and I stratified accident_type over years 2010-2015. I used the following code:
graph bar, over(accident_type) over(years)
*note I had to use over(accident_type) because it's a string variable and the graph wouldn't let me use time-series operators, luckily over() fixes this problem
But as you can imagine, displaying 20 values and stratified over 6 years over a bar graph can be quite squished and hard to read so I wanted to display only the value "violence" in accident_type. I used the following code:
graph bar if accident_type=="violence", over(accident_type) over(years)
However, this code recalculates the percentage of "violence" as if now I've created a subpopulation where I restricted the dataset to look only at those with "violence" in accident_type. For example, in the first graph "violence" in 2010 was perhaps 5%, and in the second graph "violence" in 2010 is now 25%. I didn't want to restrict the population and recalculate the proportions; I only wanted to restrict the graph to only show "violence". Is there a way to do this?
Comment