Hi Statalist
My question is about creating a stacked bar chart for panel data. To illustrate:
From this I want to see the changing composition of, say, the various regions over time (it doesn't change in this made-up example but in my actual dataset there are differences over time).
Question: What I would like to do is to graph the above two-way tabulation table like the following using Stata.
The code I tried so far is
which doesn't work. Any suggestions would be greatly appreciated.
Thanks
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
Comment