Statalist


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

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


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: How to make a for "loop" when the counter is a variabe
Date   Tue, 19 Jan 2010 14:43:07 +0100

<> 


" 
forv i=1/`=`var'' {
	...
}
"


*************
sysuse auto, clear
forv i=1/`=`mpg'' {
	di `i'
}
*************

gives me an error. (mpg is not the name of a -local-, is it?)


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Jeph Herrin
Gesendet: Dienstag, 19. Januar 2010 14:38
An: [email protected]
Betreff: Re: st: How to make a for "loop" when the counter is a variabe


forv i=1/`=`var'' {
	...
}


hth,
Jeph


Quang Nguyen 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?
> 
> Many thanks!
> 
> --
> "My father gave me the greatest gift anyone could give another person,
> he believed in me." - Jim Valvano
> 
> *
> *   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/
> 
*
*   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/


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