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]
st: Looping over datetimes for simultaneous variable generation
From
Paul Balcombe <[email protected]>
To
"[email protected]" <[email protected]>
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.
Thanks,
Paul
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/