Hi,

For my research I spend a lot of time looking at trends in the distribution of categorical variables as a function of time, career length, and so forth. Since as far as I can tell STATA doesn't have native capability for stacked area graphs, I created a module called stackedcount that would produce plots with the frequencies of the categories of a variable stacked on the vertical axis against a discrete numeric variable like year, age, career length on the horizontal axis. The initial inspiration was a 2018 post in a thread on stacked area graphs by Andrew Musau.

The module is available via ssc install stackedcount. It includes a sthelp file.

For more details, I have a post about it at my blog that includes some sample code and the resulting figures.

Here is a sample:



stacked_count chushen year if xuhao < 20000 & !qiren & ming != "" & year >= 1830 & !central & !fangkeben_only & !irregular & !ignore & !new_in_1911, xtitle("Year") xtick(1830(5)1910) xmtick(1830(1)1910) xlabel(1830(10)1910) ytitle("Records of officials") ylabel(0(2000)8000,labsize(small)) ymtick(0(1000)8000) legend(cols(4) size(vsmall))

I hope others find this useful.

I have a companion module called stackedpercent that I will submit to SSC in a little bit.