Statalist


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

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


From   Neil Shephard <[email protected]>
To   [email protected]
Subject   Re: st: How to make a for "loop" when the counter is a variabe
Date   Tue, 19 Jan 2010 13:38:44 +0000

On Tue, Jan 19, 2010 at 1:22 PM, Quang Nguyen <[email protected]> wrote:
> When I run the following code:
>
> for i = 1/`var' {........
>                    }
>
> where var is a variable in the data set.
>
> The code doesn't work. Can you suggest a solution?


qui sum `var'
for i = 1/`r(N)'{
}

But I suspect this isn't really what you want and there is likely a
better/cleaner solution.  If you could provide greater context such a
solution might be forthcoming.

Neil


-- 
"... no scientific worker has a fixed level of significance at which
from year to year, and in all circumstances, he rejects hypotheses; he
rather gives his mind to each particular case in the light of his
evidence and his ideas." - Sir Ronald A. Fisher (1956)

Email - [email protected]
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/

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