Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Arya Eskamani <Arya.Eskamani@assist-rx.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: Graphing multiple series groups |
Date | Thu, 11 Apr 2013 21:25:54 +0000 |
Oh sweet! This is an excellent resource, it's going to make my life a lot easier moving forward. Thank you very much. Arya Eskamani, M.S. Project Manager 4700 Millenia Blvd | Ste 500 | Orlando, FL 32839 407.367.2880 Phone | 877.313.4412 eFax www.assist-rx.com | arya.eskamani@assist-rx.com -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of David Radwin Sent: Thursday, April 11, 2013 5:03 PM To: statalist@hsphsun2.harvard.edu Subject: RE: st: Graphing multiple series groups 5000 seems like a lot of lines for one graph, but you could write: forvalues i = 1/5000 { local graphs `graphs' (line yvar xvar if group == `i') } graph twoway `graphs' A nice introduction to foreach and forvalues loops is Kit Baum's "A little bit of Stata programming goes a long way..." at http://fmwww.bc.edu/ec-p/wp612.pdf . His introductory Stata programming book is also an excellent way to learn such things. David -- David Radwin Senior Research Associate MPR Associates, Inc. 2150 Shattuck Ave., Suite 800 Berkeley, CA 94704 Phone: 510-849-4942 Fax: 510-849-0794 www.mprinc.com > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner- > statalist@hsphsun2.harvard.edu] On Behalf Of Arya Eskamani > Sent: Thursday, April 11, 2013 1:34 PM > To: statalist@hsphsun2.harvard.edu > Subject: RE: st: Graphing multiple series groups > > Hello Statalisters > > I'm attempting to find an easier equivalent of the following: > > graph twoway /// > line yvar xvar if group == 1 || /// > line yvar xvar if group == 2 || /// > line yvar xvar if group == n || > > I'm interested in showing how the different "groups" compare to each other > all on one graph, not separate the groups into different graphs. Now > if my dataset only has a small number of groups this is easy enough, > but suppose I had 5000 groups, this method means I have to write 5000 > lines for each group. Is there an easier way to create the equivalent > above without writing so much code? Thank you. > > Arya Eskamani, M.S. > Project Manager > 4700 Millenia Blvd | Ste 500 | Orlando, FL 32839 > 407.367.2880 Phone | 877.313.4412 eFax www.assist-rx.com | > arya.eskamani@assist-rx.com > > > * > * 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/ * * 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/ * * 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/