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

# st: Working with time series operators and loops in If Qualifier

 From Hauptseminar@gmx.de To statalist@hsphsun2.harvard.edu Subject st: Working with time series operators and loops in If Qualifier Date Thu, 05 May 2011 17:48:37 +0200

```Dear stata  experts,

I am trying to integrate time operators and a loop in a if qualifier.

Here is my code:

forvalues x = 1/10 {
forvalues z = 1/100 {

gen hrec_`z'_`x' = 0

gen hrec_start_`z'_`x' = 0

replace hrec_`z'_`x' = 1 if L(1/`x').(abc >= `z'/100) & ( vw >= 0 | dvw >=0)

replace hrec_start_`z'_`x' = 1 if hrec_`z'_`x'==1 & L1.hrec_`z'_`x'==0

replace hrec_`z'_`x'=0 if (abc < `z'/100 | vw<=0) & hrec_start_`z'_`x' ~=1
}
}

Stata wont let the time operator L(1/`x') work in the if qualifier and I understand the reason for this. Unfortunately, I have no clue how to write the code of this instead.

I want the if qualifier to check if 1 to x lagged values are above a numerial value without typing every single qualification. Do you have any advice how to solve this problem?

Thanks a lot,

Kathy

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```