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 <[email protected]>
To   [email protected]
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:[email protected]]
> Sent: 2. juli 2002 14:10
> To: [email protected]
> 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
> [email protected]
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index