I have two categorical variables x (values: 0, 1) and y (values: 0-7) and I have also generated an ID by gen ID = _n. I can get the row percentages by the following syntax.
tab x y, row
My goal is to get a graph similar to the following graph with row percentages represented by the bars within each category of x. I used the following syntax to produce the graph of counts.
graph bar (count) id, over(y) over(x) title(Cluster 1) ytitle(Count) b1title(Number of conditions)
But when I use the following syntax it gives me cell percentages in the bars.
graph bar (percent) id, over(y) over(x) title(Cluster 1) ytitle(Percent) b1title(Number of conditions)
But what I want is the row percentages in the bars, not the cell percentages. In other words, I want the percentages within the total of each category of x. Just like plotting the row percentages information found in
tab x y, row
Could you please tell me how I can do this in Stata?
tab x y, row
My goal is to get a graph similar to the following graph with row percentages represented by the bars within each category of x. I used the following syntax to produce the graph of counts.
graph bar (count) id, over(y) over(x) title(Cluster 1) ytitle(Count) b1title(Number of conditions)
But when I use the following syntax it gives me cell percentages in the bars.
graph bar (percent) id, over(y) over(x) title(Cluster 1) ytitle(Percent) b1title(Number of conditions)
But what I want is the row percentages in the bars, not the cell percentages. In other words, I want the percentages within the total of each category of x. Just like plotting the row percentages information found in
tab x y, row
Could you please tell me how I can do this in Stata?
Comment