I doubt it. -for- itself is a command. The fact
that it runs other commands is not reflected
by what the profiler reports, as is explained
in the help Mark quotes here.
A quite different comment is beware -for-
and the habit of trying to write miniature programs
as a single call to -for-. It is cute when it
works but very inefficient and all too likely to bite you.
Nick
[email protected]
Mark Schaffer
> Try -profiler-; it will probably do what you want. From the
> help file:
>
> "profiler is a programmer's command that can help in
> optimizing ado-files
> and other Stata programs. When profiling is turned on,
> profiler on, Stata
> begins keeping a record of each time a program is run and how
> much time is
> spent in the program."
David K Evans
> > Is there a simple way to see how much time has elapsed while a
> > command in the midst of a "for" loop is running?
> >
> > Outside of a loop, I just "set rmsg on" and can see how long each
> > command takes.
> >
> > But if I have, for example,
> >
> > for num 1/10: preserve \ keep if age==X \ reshape [blah blah blah]
> > \
> > save ageX.dta, replace \ restore;
> >
> > and I want to know how long the reshaping took, I'm not sure how to
> > find out. "set rmsg on" only gives me the time for the entire loop.
> >
> > I know about macros to display the time, but I'm not sure how to
> > manipulate them to calculate time elapsed.
*
* 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/