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/