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

st: Problem creating multiple loops

From   "Hugh Colaco" <>
To   statalist <>
Subject   st: Problem creating multiple loops
Date   Fri, 13 Jun 2008 13:29:10 -0400


I realize that my earlier post a couple of days ago was not very
clear. So, here is another try. I need a more efficient code than the
one below. I tried various combinations of -local-, -foreach- and
-forval-, but am unable to get it right.

       gen var1_1 = ln(((var1_1994-var1_1993)/var1_1993)+1) if year==1993;

       gen var1_2 = ln(((var1_1995-var1_1993)/var1_1993)+1) if year==1993;

       gen var1_3 = ln(((var1_1996-var1_1993)/var1_1993)+1) if year==1993;

       gen var1_4 = ln(((var1_1997-var1_1993)/var1_1993)+1) if year==1993;

       replace var1_1 = ln(((var1_1995-var1_1994)/var1_1994)+1) if year==1994;

       replace var1_2 = ln(((var1_1996-var1_1994)/var1_1994)+1) if year==1994;

       replace var1_3 = ln(((var1_1997-var1_1994)/var1_1994)+1) if year==1994;

       replace var1_4 = ln(((var1_1998-var1_1994)/var1_1994)+1) if year==1994;




       replace var1_1 = ln(((var1_2003-var1_2002)/var1_2002)+1) if year==2002;

       replace var1_2 = ln(((var1_2004-var1_2002)/var1_2002)+1) if year==2002;

       replace var1_3 = ln(((var1_2005-var1_2002)/var1_2002)+1) if year==2002;

       replace var1_4 = ln(((var1_2006-var1_2002)/var1_2002)+1) if year==2002;

Thanks in advance,
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index