Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: AW: Syntax forvalues in Stata 11 SE


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: Syntax forvalues in Stata 11 SE
Date   Thu, 23 Sep 2010 13:55:33 +0200

<> 


How and when is -local- "max1" defined in your code? See this code:


*************
loc max1 2
forv i=1/`max1'{
di `i'
}

loc max1
forv i=1/`max1'{
di `i'
}
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Gauri Khanna
Gesendet: Donnerstag, 23. September 2010 13:53
An: Stata List
Betreff: st: Syntax forvalues in Stata 11 SE


Hi, 

I am a new user to the Stata 11.1 SE 

I have run into syntax problems with the - forvalues- command while creating
a loop. 

My syntax which comes from Stata 9 is the following:

forvalues svy = 1/`max1' { 
    use "'allsvys'", clear
    keep if i==`svy'
}

and I get the following error : 

invalid syntax
r(198);

Subsequently, i would also like to run the following syntax (shortened for
convenience)

foreach x of local names {
        if "`x'"=="lgsmkc" {        
            display "`x'"
            gen row`j'=lgcigc 
            local j=`j'+1
        }
}

Can anyone help? 

Gauri 

 		 	   		  
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index