Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Three-way (or more) histograms in Stata


From   Tim Evans <Tim.Evans@wmciu.nhs.uk>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Three-way (or more) histograms in Stata
Date   Tue, 9 Oct 2012 14:45:32 +0100

Hi all,

I am trying to generate histograms (in Stata 11.2) with age distributions for three categories overlaid in the same graph for different periods. Essentially I want to visually check whether the age distribution of the cohort in an age group changes between periods, and whether the distribution of sub groups of the population also change. 

I started off with -histogram- because this nicely collapses my patient level data, without me having to do this manually. However, while I found twoway to be an option to increase the number of series plotted on the graph, I guess what I'm really after are line plots which would allow transparency between the series.

I'm using the followinhg code to present single categories of interest (but for each level in my age group) and use the -by()- to present all periods on one combined graph (separate for each age group)

levelsof age_grp, local(levels)
foreach l of local levels {
histogram Age_At_Diag if age_grp==`l' & yydx!=., discrete percent /*
*/ yscale(range(20)) /* 
*/ ylabel(0(5)20 , gmax  angle(horizontal) format(%3.0f)) /*
*/ xtitle("Age at diagnosis") /*
*/ by(period, row(1) note("Graphs by period of diagnosis in `: label (age_grp) `l'' age group") /*
*/ t1title("Age distribution by diagnosis period",  size(medsmall)) legend(off)) /*
*/ name(graph`l', replace) 
 graph export Age_grp_distribution_`: label (age_grp) `l''.png, replace

}


My questions are: 

Can I ask -histogram- to plot lines rather than bars?
Can -histogram- (with lines if possible) plot more than 2 series of data

If -histogram- will not do this, what is a better method of doing this?

Best wishes

Tim
_DISCLAIMER:
This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index