Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: combining many -twoway (histogram)- graphs


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: combining many -twoway (histogram)- graphs
Date   Tue, 11 Feb 2003 20:08:49 -0000

Daniel M�ller

> > I would like to combine several histograms with:
> > -------------------
> > . use evaluation, clear
> >
> > . forvalues i = 1(1)10 {
> >   2.         twoway (histogram q`i', discrete frequency),
> xlabel(1(1)5)
> > name(q`1', replace) scheme(sj)
> >   3. }
> >
> > . graph combine q1-q10
> > q1-q10 is not a memory graph
> > invalid syntax
> > invalid syntax
> > r(198);
> > -------------------
> >
> > I can only combine up to two graphs with -graph combine
> q1 q2-. From three
> > onwards, I receive the same error message as above.
> >
> > Is there a workaround? Or another option to combine the multiple
> > histograms?

Lee Sieswerda

> It looks to me like "q1-q10" is not being expanded. Try
> typing out the graph
> names in full.

To expand on Lee's comment, this wildcard is appropriate for varlists,
but this argument is not a varlist.

In addition you will be bitten by a typo. Revisiting your code,
I will pick nits:

=============== code with NJC comments
use evaluation, clear

forvalues i = 1(1)10 {

// OK, but learn to save keystrokes by
// forval i = 1/10 {

	twoway (histogram q`i', discrete frequency), ///
	xlabel(1(1)5) name(q`1', replace) scheme(sj)

// typo: you have `1' there instead of `i'

}

graph combine q1-q10
// invalid use of wildcard
==============

============== try this instead
use evaluation, clear

forval i = 1/10 {
	local I "`I' q`i'"
	twoway (histogram q`i', discrete frequency), ///
	xlabel(1/5) name(q`i', replace) scheme(sj)
}

graph combine `I'
==================




Nick
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index