[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Gabi Huiber" <[email protected]> |

To |
[email protected] |

Subject |
st: do-files as programs |

Date |
Thu, 25 Sep 2008 12:47:51 -0400 |

I am comparing two ways to solve the same problem and I can't see why one of them runs more quickly, but it looks that way. Is there any reason why do-files declared as programs might run faster? Suppose you have a do-file call another a few times, inside a loop, like so: _____ example 1 starts here // this is my main file forvalues i=1/`numberoftimes' { [declare some parameters as globals] do mysubfile.do // uses the set of parameters declared above } _____ example 1 ends here In example 1, mysubfile.do is just a sequence of Stata commands. Now suppose that you edit mysubfile.do with these lines ___ capture prog drop mySubfile prog def mySubfile [content of old mysubfile.do goes here] end ___ This will then require that you run the code in example 1 as follows: _____ example 2 starts here // this is my main file do mysubfile.do forvalues i=1/`numberoftimes' { [declare some parameters as globals] mySubfile // uses the set of parameters declared above } _____ example 2 ends here It seems to me that example 2, while slightly more work to write up, runs noticeably faster. Am I imagining things? Thank you, Gabi * * 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/

**Follow-Ups**:**st: RE: do-files as programs***From:*"Martin Weiss" <[email protected]>

- Prev by Date:
**Re: st: RE: testing for endogeneity with cluster()** - Next by Date:
**st: R: Estimating the probability of censoring** - Previous by thread:
**st: Estimating the probability of censoring** - Next by thread:
**st: RE: do-files as programs** - Index(es):

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