Bookmark and Share

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

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

st: Looping over datetimes for simultaneous variable generation

From   Paul Balcombe <>
To   "" <>
Subject   st: Looping over datetimes for simultaneous variable generation
Date   Thu, 3 Oct 2013 09:18:10 +0000

I have a timeseries data set and I want to generate a number of variables that are conditional on each other and their previous values, so I want to create a value for the set of variables at each time period in my data. I thought I should use a forvalues command, but this is new to me and I have so far been unsuccessful: invalid syntax. below is the command I wish to make:
forvalues datetime= ‘tc(19aug2012 00:00:00)’ (‘tc(00:05:00)’) ‘tc(18aug2013 23:00:00)’ { 
                replace seen=seen[_n-1] if seen==. & seen3[_n-1]<seen[_n-1]
                replace segaspow=segaspow[_n-1] if seen==. & seen3[_n-1]<seen[_n-1]
                replace seen2=seen2[_n-1] if seen==. & seen3[_n-1]<seen[_n-1]
                replace seen3=seen2+seen3[_n-1] if seen==. & seen3[_n-1]<seen[_n-1]
I may be describing the datetime functions incorrectly.
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index