Statalist


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

st: Help with loops


From   Rijo John <[email protected]>
To   stata <[email protected]>
Subject   st: Help with loops
Date   Thu, 15 May 2008 15:35:16 -0500

hi, I have the following that gives results the way I wanted.

local varlist1 "var1 var2 var3 var4 "
foreach i in 1 2  3{
	foreach X of local varlist1{
            gen `X'_y`i'=`X'_y
	    replace `X'_y`i' = `X'_y+(`X'_y*`i')
	}
}

However, if I change values 1, 2, 3 to 0.01, 0.02 and 0.03 it gives me
the error saying "var1_y0.01 invalid name". As I understand variables
can not be named with dots in it? if so how do I get around? how can I
modify it to generate variabes such as var1_y1=var1-(var1_y*0.01) and
so on.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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