Statalist


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

st: Help with loops


From   "[email protected]" <[email protected]>
To   stata <[email protected]>
Subject   st: Help with loops
Date   Fri, 16 May 2008 07:39:20 -0700

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/

_____________________________________________________________________
Mensaje analizado y protegido por Telefonica Empresas
*
*   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/

Privileged, confidential or patient identifiable information may be contained in this message. This information is meant only for the use of the intended recipients. If you are not the intended recipient, or if the message has been addressed to you in error, do not read, disclose, reproduce, distribute, disseminate or otherwise use this transmission. Instead, please notify the sender by reply e-mail, and then destroy all copies of the message and any attachments.

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