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 |
Nick Cox <njcoxstata@gmail.com> |

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

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

Date |
Tue, 20 Dec 2011 14:16:30 +0000 |

-catplot- (SSC) automates this. Nick

Dear List My data was set up like this Cause of death age_gr 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 After googleing and a little crying i found this: http://stata.com/statalist/archive/2008-05/msg01072.html Then i did the following: . gen frequency = 1 . graph bar (sum) frequency, over(group) over(age_gr) asyvars That did the trick. Merry christmas! Lars Den 20/12/11 13.51 skrev "Scholes, Shaun" <s.scholes@ucl.ac.uk>:This sounds like something I was playing with a couple of weeksago. Icame up with the following to match one of the figures in a paper Iwasreading:ID year cause1 cause2 cause3 cause4 cause5cause6 cause71 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 yearlblgraph bar (asis) cause1 cause2 cause3 cause4 cause5 cause6cause7,stackover(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 agegroup would replace 'year' in this example; and you would have 12causesrather 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 MuhammadAneesSent: 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 barcharts. Iam 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 listI have two variables (causes of death and age groups) And i wanttopresent them as a bar - chart.The idea is that the x axis will contain the age groups 0 10 2030 ...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 10persons died of causes within category 1 there will be a spikeof 10on 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/* * 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/

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

- Prev by Date:
**Re: st: Graph of two grouping variables** - Next by Date:
**Re: st: rounding error** - Previous by thread:
**Re: st: Graph of two grouping variables** - Next by thread:
**Re: st: Graph of two grouping variables** - Index(es):