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

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

From |
"Scholes, Shaun" <s.scholes@ucl.ac.uk> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Graph of two grouping variables |

Date |
Tue, 20 Dec 2011 12:51:01 +0000 |

This sounds like something I was playing with a couple of weeks ago. I came up with the following to match one of the figures in a paper I was reading: ID year cause1 cause2 cause3 cause4 cause5 cause6 cause7 1 1 150 25 28 31 13 7 77 2 2 125 38 28 38 12 3 55 3 3 129 38 38 27 26 16 71 4 4 134 35 47 28 20 19 68 5 5 103 39 31 24 27 21 68 label define yearlbl 1 "1981" 2 "1986" 3 "1991" 4 "1996" 5 "2001" label values year yearlbl graph bar (asis) cause1 cause2 cause3 cause4 cause5 cause6 cause7,stack over(year) /// legend(order(1 "CHD" 2 "Lung" 3 "Cancer" 4 "Lungdis" 5 "Injury" 6 "Suicide" 7 "Other")) /// ytitle("Title") ylabel(0 100 200 300 400,ang(hor)) bar(1,color(black)) bar(2,color(gray)) title("Males",pos(11)) I'm a novice with graphs...but this seemed ok for my purposes. So age group would replace 'year' in this example; and you would have 12 causes rather than 7. Feel free to ignore: it may not be what you are looking for. Would be very interested, however, to know your final solution! Shaun -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Muhammad Anees Sent: 20 December 2011 12:19 To: statalist@hsphsun2.harvard.edu Subject: Re: st: Graph of two grouping variables Then I would suggest to take hints from http://www.stata.com/support/faqs/data/percentvars.html On Tue, Dec 20, 2011 at 5:07 PM, Lars Folkestad <lfolkestad@health.sdu.dk> wrote: > Dear Muhammad and Nick > Thank you for your fast answers. > I actually want something like the asyvars shown here > http://www.ats.ucla.edu/stat/stata/faq/barcap.htm > But i cannot figure out how to do it with two categorical variables > and to count the data so that i get on the y-axis the sum of > obeservations with in the 12 categories within the different age > groups (0-100) lars > > Den 20/12/11 12.54 skrev "Nick Cox" <njcoxstata@gmail.com>: > >>-tabplot- (SSC) pushes the very simple idea of two-way bar charts. I >>am not clear that it is what you ask for, but it could be useful >>nevertheless. The bars don't touch by default, but that's tunable. >> >>Nick >> >>On Tue, Dec 20, 2011 at 11:47 AM, Lars Folkestad >><lfolkestad@health.sdu.dk> wrote: >>> Dear list >>> >>> I have two variables (causes of death and age groups) And i want to >>> present them as a bar - chart. >>> >>> The idea is that the x axis will contain the age groups 0 10 20 30 ... >>>100 >>> years >>> >>> For every age group i want the total number (or percent) of >>> observation within the 15 categories i have defined so that if 10 >>> persons died of causes within category 1 there will be a spike of 10 >>> on the y axis, and similarly for the other categories. >>> >>> The variables are: >>> Cod is an integer of 1-12 >>> >>> And age_gr: integer from 0-100 in 10 year intervals >>> >>> Hope that made sense. >>> >>> lars >>> >>> >>> * >>> * For searches and help try: >>> * http://www.stata.com/help.cgi?search >>> * http://www.stata.com/support/statalist/faq >>> * http://www.ats.ucla.edu/stat/stata/ >> >>* >>* For searches and help try: >>* http://www.stata.com/help.cgi?search >>* http://www.stata.com/support/statalist/faq >>* http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ -- Best --------------------------- Muhammad Anees Assistant Professor/Programme Coordinator COMSATS Institute of Information Technology Attock 43600, Pakistan http://www.aneconomist.com * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Graph of two grouping variables***From:*Lars Folkestad <lfolkestad@health.sdu.dk>

**References**:**Re: st: Graph of two grouping variables***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Graph of two grouping variables***From:*Lars Folkestad <lfolkestad@health.sdu.dk>

**Re: st: Graph of two grouping variables***From:*Muhammad Anees <anees@aneconomist.com>

- Prev by Date:
**Re: st: Graph of two grouping variables** - Next by Date:
**st: multilevel multinomial logit predicted probabilities** - Previous by thread:
**Re: st: Graph of two grouping variables** - Next by thread:
**Re: st: Graph of two grouping variables** - Index(es):