Christopher F Baum
>
> I don't know what you mean by 'in the log file' since
> graphs do not appear
> in the log file (which is a text file) in any case. However
> you can use the
> 'saving' option in the graph command to create graph files, e.g.
> saving(g`var',replace) which will create gx1.gph, gx2.gph,
> etc (which would
> probably be more useful if the variables had more descriptive names.
>
> You may then use something like
> graph using gx1 gx2 gx3 gx4 gx5 gx6 gx7 gx8 gx9
> to view all the graphs on one screen.
>
> Also note that if your variables are named like this, you could do
>
> forv i=1/9 { graph x`i' y, by(z) saving(gx`i',replace)
>
Let me add a couple of details.
First, you need to watch lines like
. forv i=1/9 { graph x`i' y, by(z) saving(gx`i',replace) }
-- adding the "}" omitted by accident --
in which Stata is presented with everything on one
line. This is not _guaranteed_ to work. If the whole
is relatively simple, it will; but not otherwise.
However, that's circular, as "relatively simple"
is defined by it working.
The syntax you should follow with -forvalues-
or -foreach- puts each command within the loop
on a separate line, namely
. forv i=1/9 {
. graph x`i' y, by(z) saving(gx`i',replace)
. }
In practice, you can often put the last
brace } on the same line as the command before
it, as in
. graph x`i' y, by(z) saving(gx`i',replace) }
I don't think I've seen Stata complain at
that, although that's Stata's indulgence
rather than recommended syntax.
Second, and more positively, I often loop
something like this
forval i = 1/9
graph <whatever> if something == `i', t1(`i') saving(g`i')
more
}
The two extra details are the -more-, which ensures
a slide show not a movie, and a title which
shows which group you are seeing.
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/