Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: foreach loop


From   R Zhang <[email protected]>
To   [email protected]
Subject   st: foreach loop
Date   Wed, 15 Jan 2014 12:34:07 -0500

Hi Statalisters,

I use the following code to generate lags and leads

sort gvkey year
tsset gvkey year

foreach x in cover  dred eiss ered ndiss neiss nlevup tfina {

gen `x'_D1=D.`x'
  gen `x'_L1=L.`x'

  gen `x'_L2=L2.`x'

  gen `x'_F1=F.`x'

  gen `x'_F2=F2.`x'
}

what puzzles me is that when I use summarize command to check values
of the lags for neiss nlevup tfina , stata says variables neiss_L1,
nlevup_L1, tfina_L1,not found.

neiss nlevup tfina  are not missing. and the lags for dred eiss ered
ndiss were created.

what did i do wrong?

thanks,
-Rochelle
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index