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: RE: RE: appending graphs


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: appending graphs
Date   Sat, 26 Jun 2010 00:29:39 +0200

<>

Example:


*************
clear*

set obs 4
gen byte school = _n

expand 4
bys school: gen byte subject=_n+3

expand 100 
bys school subject: gen byte time=_n

gen myvar=rnormal()+subject*3

qui levelsof school

foreach lev in `r(levels)'{
	xtline myvar if school==`lev',  /// 
	title("Graph for school `lev'") /// 
	overlay i(subject) t(time) /// 
	name(gr`lev', replace) nodraw
}

graph combine gr1 gr2 gr3 gr4
*************


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Weiss
Sent: Samstag, 26. Juni 2010 00:17
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: appending graphs


<>

Have you had a look at -h xtline- yet? 


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Lim, Raymond
Sent: Freitag, 25. Juni 2010 21:24
To: statalist@hsphsun2.harvard.edu
Subject: st: appending graphs

Hi Statalisters,
Is there a way to append graphs? I want to automate producing graphs by a
categorical variable, with with different number of lines. 
For example, Say you are creating time series graph of GPA by school and by
subject (subject 1...20, each school offering a combination of them). Thus
for each school, you have a graph with 3 to 5 different lines representing
GPA in different subjects across time. The command would be something along
the lines of

#delimit ;
tsset school year;
twoway (tsline mean if school==1 & subject==7) 
	 (tsline mean if school==1 & subject==8) 
	 (tsline mean if school==1 & subject==9);
twoway (tsline mean if school==2 & subject==4) 
	 (tsline mean if school==2 & subject==8);
twoway (tsline mean if school==2 & subject==1) 
	 (tsline mean if school==2 & subject==2);

Etc...

I want to write a loop that will add lines to the graph as long as there are
subjects that still need to graphed. I was thinking about using a for-loop,
but I need to repeat "(tsline mean if school==__ & subject==__)" until all
the subjects are accounted for.

Thanks for any input!
-Raymond

*
*   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/


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