Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: nested loops with varying degrees of nesting

From   David Kantor <>
Subject   Re: st: nested loops with varying degrees of nesting
Date   Wed, 02 Oct 2013 12:49:13 -0400

At 06:19 PM 10/1/2013, Nick Cox wrote:
I would write this in terms of variable loop counts. Assume here that
I, J, K are defined previously.

forval i = 1/`I' {
    forval j = 1/`J' {
         forval k = 1/`K' {


If any of the loop counts is 1, there is no great loss. (If absolutely
nothing is done in such a case, condition inside on the loop count
being 2 or more.)

Shorter code and easier to follow.

Thanks very much for that idea. It will probably be the route I pursue.
Also thanks to Phil Schumm for suggesting recursion; I will also look into that idea.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index