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

From |
Mark Hanly <m.hanly@ucl.ac.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: forvalues in Stata 7 - is there a Stata 6 equivalent? |

Date |
Wed, 17 Dec 2003 18:22:44 +0000 |

Thanks Nick for your prompt and informative reply. I'll try using 'while' to see what it does. Mark At 18:08 17/12/2003 +0000, you wrote:

The short answer is No. -forvalues- was introduced in Stata 7. A longer answer is: use -while-. forval i = 1/6 { ... } as one example can be mapped to local i = 1 while `i' <= 6 { ... local i = `i' + 1 } The key differences are that with -while-, you must initialise whatever you use to loop and you must increment the macro yourself. So -while- imposes more overhead in interpretation than -forvalues-, but often you'd find it hard to see how much. Similar comments could be made about decrementing, stepping by steps other than 1, etc. Some may answer -for-. for num 1/6 : <statements referring to X> is another way of looping through, and you don't need to initialise or increment yourself. However, -for- has been abandoned, and there are lots of reasons why it is often not a good idea. For one take on that, see articles in Stata Journal 2(2):202--222 (2002) and 3(2):185--202 (2003). Notes of a talk based on a draft of the first are accessible at various places of the web, including http://fmwww.bc.edu/RePEc/usug2002/fortitude.pdf Nick n.j.cox@durham.ac.uk Mark Hanly > > I am running Stata 6 on my pc and trying to adapt some code > written for > Stata 7 (to which I have access on a network, but which > takes an age to run). > > Is there a command (or sequence of commands) in Stata 6 > which does the same > thing as the command 'forvalues' in Stata 7? * * 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/

Mark Hanly Research Fellow ESRC Transport Studies Unit University College London London WC1E 6BT tel +44 (0)20 7679 1584 fax +44 (0)20 7679 1567 www.cts.ucl.ac.uk www.cts.ucl.ac.uk/seminars * * 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/

**References**:**st: forvalues in Stata 7 - is there a Stata 6 equivalent?***From:*Mark Hanly <m.hanly@ucl.ac.uk>

**st: RE: forvalues in Stata 7 - is there a Stata 6 equivalent?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: forvalues in Stata 7 - is there a Stata 6 equivalent?** - Next by Date:
**Re: st: RE: Taking averages, etc.** - Previous by thread:
**st: RE: forvalues in Stata 7 - is there a Stata 6 equivalent?** - Index(es):

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