Statalist The Stata Listserver

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

st: looping over parallel lists - is there a alternative to "for"?

From   Gawrich Stefan <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: looping over parallel lists - is there a alternative to "for"?
Date   Thu, 16 Mar 2006 11:58:36 +0100


I do a lot of routine or repetitive data analysis and use loops and lists
frequently (btw, thx to Nick Cox, his "How to fact lists with fortitude"
helped me a lot).

I'm wondering why the "for"-command is officialy out of date in Stata while
one of it's best features  - the use of parallel lists - can't be done
otherwise. Or am I missing something? 

One example: I routinely map ten different diseases with tmap and save the
maps as a graphic file. 

for var var1-var10 \ any "Disease1" "Disease2" [...] \ any "Filename1"
"Filename2" [...] : ///
tmap choro X, id(county) map("county-Coordinates.dta") title("Y") \ graph
export "Z.png", replace 

In this example each graph is determined by something like a 3-tuple of
variable, title and saving-filename. 
This is just basic code, in real life the code blows up and becomes hard to
read, as we all know, "for" has some disadvantages.  
So if it can be done in a more structured manner, I would like to know...

Best wishes 

Dr. Stefan Gawrich
Hesse State Health Office
Wolframstr. 33
35683 Dillenburg


*   For searches and help try:

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