Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: time-series operator in -foreach- loop


From   Finne Håkon <Hakon.Finne@sintef.no>
To   statalist@hsphsun2.harvard.edu
Subject   st: RE: time-series operator in -foreach- loop
Date   Tue, 2 Jul 2002 14:53:17 +0200

Ooops, wrong diagnosis, problem solved. The problem was in using -foreach i
in 1/10- instead of -foreach i of numlist 1/10- . With the first approach,
1/10 is the first and only element of the list, so D`i'.group==1 is
substituted to D1/10.group==1 , which the parser interprets as D1 divided by
<something>, but the <something> is not interpreted because the variable D1
is not found.

-- Håkon

> -----Original Message-----
> From: Finne Håkon [mailto:Hakon.Finne@sintef.no]
> Sent: 2. juli 2002 14:10
> To: statalist@hsphsun2.harvard.edu
> Subject: st: time-series operator in -foreach- loop
> 
> 
> Dear Statalisters,
> 
> With data -tsset- :
> 
> . gen event = 0
> 
> . foreach i in 1/10 {
>   2. replace event = 1 if D`i'.group==1
>   3. }
> D1 not found
> r(111);
> 
> . replace event = 1 if D1.group==1
> (6589 real changes made)
> 
> . 
> Why doesn't -foreach- read D1. as a time series operator, and 
> which is the
> better workaround?
> 
> -- Håkon
> hakon.finne@sintef.no
> *
> *   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/
> 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index