The fallacy that foreach i in varname in Stata somehow loops over the distinct values of varname was also discussed in #6. It would be of interest to know how it arises, perhaps just through wishful thinking or perhaps because some people are coming to Stata knowing more about programming in other software where it does exactly that.
I tried my hand at fairly basic tutorials on loops in
which papers are each second editions of papers published about 20 years earlier.
I tried my hand at fairly basic tutorials on loops in
Code:
SJ-21-4 pr0075 . . . . . . . . . . . . . . Speaking Stata: Loops in parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/21 SJ 21(4):1047--1064 (no commands) tutorial discussing looping in parallel using foreach and forvalues SJ-21-2 pr0074_1 . . . . . . Erratum: Speaking Stata: Loops, again and again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q2/21 SJ 21(2):555 (no commands) erratum for a line of code SJ-20-4 pr0074 . . . . . . . . . . . . Speaking Stata: Loops, again and again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/20 SJ 20(4):999--1015 (no commands) provides updated guidance on using foreach and forvalues for looping through lists of values and repeating commands using members of those lists in turn
which papers are each second editions of papers published about 20 years earlier.
Comment