Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: How to overlay multiple twoway bar graphs?

From   "McDermaid, Cameron" <[email protected]>
To   <[email protected]>
Subject   st: How to overlay multiple twoway bar graphs?
Date   Thu, 15 Sep 2011 08:48:47 -0400

I want to graph duration of disease outbreaks against the date of occurrence by aetiological agent for multiple sites so each site will have its own summary graph.  I've been trying to generate bar graphs such that duration is on the y-axis, date of onset along the x-axis and each aetiological agent represented by it's own bar colour.

I can get the result I want by manually using || to overlay bar graphs where each additional plot represents the duration and onset date of a particular aetiological agent. 
twoway bar duration index_date if site==2 & aetiologicagent=1 || duration index_date if site==2 & aetiologicagent=4

However, I’d like to script this. I have 24 sites and not all sites had outbreaks with the same aetiological agents and, over time, the within-site agents may change depending on the time period. That’s a lot of recoding if I take a manual approach to write disease specific graphs.  What I’d like to do is essentially overlays the graphs generated by: 

.twoway bar duration index_date if site==2, by(aetiologicagent)

into one graph. I would loop through the instances of the sites to get summary graphs for each.   

I’ve tried a number of things without achieving the results I wanted. The only thing I haven’t tried is to generate binary dummy variables for each aetiologic agent and include them all in a graph statement as overlays using ||. I’d expect the instances of aetiological agents that don’t exist for that institution would not be plotted.

Any suggestions of alternative solutions?

- cam
Cameron McDermaid MHSc
Ottawa Public Health
100 Constellation Cr, Ottawa ON K2G 6J8
vox: 613-580-6744x15321
fax: 613-580-9601

The beginning of wisdom is the definition of terms - Socrates

This e-mail originates from the City of Ottawa e-mail system. Any 
distribution, use or copying of this e-mail or the information it 
contains by other than the intended recipient(s) is unauthorized. 
If you are not the intended recipient, please notify me at the 
telephone number shown above or by return e-mail and delete 
this communication and any copy immediately. Thank you.

Le présent courriel a été expédié par le système de courriels de 
la Ville d'Ottawa. Toute distribution, utilisation ou 
reproduction du courriel ou des renseignements qui s'y trouvent 
par une personne autre que son destinataire prévu est interdite. 
Si vous avez reçu le message par erreur, veuillez m'en aviser par 
téléphone (au numéro précité) ou par courriel, puis supprimer 
sans délai la version originale de la communication ainsi que 
toutes ses copies. Je vous remercie de votre collaboration.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index