An example of my dataset consists of two variables as below:
Code:
clear input long year procedure 2010 1 2010 1 2010 2 2010 3 2011 1 2011 2 2011 2 2011 3 2011 3 2012 1 2012 2 2012 3 2012 3 end
Code:
tab procedure year, col
Code:
clear input long procedure year prop 1 2010 .5 1 2011 .2 1 2012 .25 2 2010 .25 2 2011 .4 2 2012 0.25 3 2010 .25 3 2011 .4 3 2012 .5 end graph bar (asis) prop, over(procedure) over(year) asyvars stack
Array
Any way to achieve the same directly from the initial dataset? Also, if a proportion is equal to zero for a certain year, the option "stack" reports an error- any way around it?
Many thanks in advance
0 Response to Stacked barchart displaying proportion of each category over different years
Post a Comment