My question is about creating a stacked bar chart for panel data. To illustrate:
Code:
. webuse citytemp ## the rest of the code is to create a made-up panel data . generate id = _n . generate year = 2000 . expand 4 . bysort id: replace year = year + _n
Code:
. tabulate region year, column nofreq
Census | year
Region | 2001 2002 2003 2004 | Total
-----------+--------------------------------------------+----------
NE | 17.36 17.36 17.36 17.36 | 17.36
N Cntrl | 29.71 29.71 29.71 29.71 | 29.71
South | 26.15 26.15 26.15 26.15 | 26.15
West | 26.78 26.78 26.78 26.78 | 26.78
-----------+--------------------------------------------+----------
Total | 100.00 100.00 100.00 100.00 | 100.00
The code I tried so far is
Code:
. graph hbar region, over(year) stack percent
Thanks

Leave a comment: