Hello everyone!
Suppose I want to create a graph bar such as:
Now, suppose I only want the bars corresponding to foreign == 1 and foreign == 2 to show. The first possible solution that came to my mind was:
but there is an evident problem, i.e. that the percentages are computed on the new restricted sample, rather than the original number of observations.
How do I avoid this?
Also, suppose that, instead of 12 different graph bars for each value of trunk, I wanted a single graph bar with trunk on the x-axis and the two columns for foreign == 1 and foreign == 2 joined side by side. How can I do that?
Suppose I want to create a graph bar such as:
Code:
clear all sysuse auto drop if trunk>16 generate index = _n gen div = index/3 gen mark = 1 if div == floor(div) replace foreign = 2 if mark == 1 graph bar (percent), over(foreign) by(trunk)
Code:
graph bar (percent) if foreign != 0, over(foreign) by(trunk)
How do I avoid this?
Also, suppose that, instead of 12 different graph bars for each value of trunk, I wanted a single graph bar with trunk on the x-axis and the two columns for foreign == 1 and foreign == 2 joined side by side. How can I do that?
Comment