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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Working with time series operators and loops in If Qualifier |

Date |
Thu, 5 May 2011 18:36:01 +0100 |

Uunfortunately for you this is indeed fantasy syntax. You have to break down L(1/`x').(abc >= `z'/100) So you first have to create gen myvar = abc >= `z'/100 and then do something like this gen true = 1 forval k = 1/`x' { replace false = 0 if L`k'.myvar == 0 } Later drop myvar true Nick On Thu, May 5, 2011 at 4:48 PM, <Hauptseminar@gmx.de> wrote: > 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? > * * 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/

**References**:**st: Working with time series operators and loops in If Qualifier***From:*Hauptseminar@gmx.de

- Prev by Date:
**Re: st: identification of particular string formats** - Next by Date:
**Re: st: how to generate mean for a secquence of five year of a variable** - Previous by thread:
**st: Working with time series operators and loops in If Qualifier** - Next by thread:
**st: trying to round values and store in a macro, problem with double/floating precision number storage** - Index(es):