Statalist


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

st: How to make a for "loop" when the counter is a variabe


From   Maarten buis <[email protected]>
To   stata list <[email protected]>
Subject   st: How to make a for "loop" when the counter is a variabe
Date   Tue, 19 Jan 2010 13:36:18 +0000 (GMT)

--- Quang Nguyen wrote:
> When I run the following code:
> 
> for i = 1/`var' {........
> }
>
> where var is a variable in the data set.

Trying to loop over observations in a 
variable is in Stata always a mistake (there 
are exceptions, but these are very very very 
very very very very very rare). Tells us what 
you want to do, and we will tell you how to 
do it, almost certainly without the loop.

-- Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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/



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