Statalist


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

st: Problem creating multiple loops


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

Hi,

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