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

From |
"Augusto Cadenas" <aug.cadenas@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Re: Running a foreach loop over a sequence of dates |

Date |
Wed, 3 Dec 2008 18:04:07 -0500 |

That's a lovely solution! Thank you very much. AC On Wed, Dec 3, 2008 at 5:52 PM, Brian P. Poi <bpoi@stata.com> wrote: >> ----- Original Message ----- From: "Augusto Cadenas" >> <aug.cadenas@googlemail.com> >> To: <statalist@hsphsun2.harvard.edu> >> Sent: Wednesday, December 03, 2008 10:02 PM >> Subject: st: Running a foreach loop over a sequence of dates >> >> Hello, >> >> I am trying to run a series of commands in a time series setting, and >> interested in using variable time intervals (variable time windows, or >> variable start/end dates). So ideally, I would like to loop with >> -foreach- over a series of dates, but I cannot find the way of doing >> this. To give you an idea of the kind of problem, here it is in >> pseudo-code (not working): >> >> *** begin pseudo-code >> >> foreach t in 1992q1/2000q4 { >> reg y L.y L.x if tin(1960q1, `t') >> reg y L.y L.x if tin(`=`t'-20', `t') >> } > > How about this: > > forvalues t = `=q(1992q1)'/`=q(2000q4)' { > reg y L.y L.x if date >= q(1960q1) & date <= `t' > reg y L.y L.x if date >= `t'-20 & date <= `t' > } > > > where date is your quarterly date variable. > > -- Brian Poi > -- bpoi@stata.com > > * > * 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/ > * * 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**:**Re: st: Re: Running a foreach loop over a sequence of dates***From:*"Brian P. Poi" <bpoi@stata.com>

- Prev by Date:
**Re: st: Re: Running a foreach loop over a sequence of dates** - Next by Date:
**Re: st: Video from multiple graph exports** - Previous by thread:
**Re: st: Re: Running a foreach loop over a sequence of dates** - Next by thread:
**st: Re: running a foreach loop over a sequence of dates** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |