Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Anti-collapsing time series data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Anti-collapsing time series data
Date   Mon, 2 May 2005 18:08:43 +0100

expand 5
bysort ID (period) : gen year = 1959 + _n 

Also, consider linear interpolation, etc. 

Nick 
[email protected] 

Johnathan Boysielal
 
> I have a cross-sectional time series data set and I would 
> like to convert 
> it to a data set of annual observations by assuming that the 
> variables 
> remained at the same level during each five year period. (I 
> would like to 
> eventually merge it with another data set)
> 
> I discovered the "expand" command but I am not quite sure how 
> to use it.
> 
> I have something that looks like:
> 
> ID      period  var1    year
> 1       1       205     .
> 1       2       220     .
> 
> and would like to do something like:
> 
> expand 5
> sort ID period
> by ID: replace year = 1960 in 1 if period==1
> by ID: replace year = year[_n-1] + 1 if missing(year)
> 
> in order to get
> 
> ID      period  var1    year
> 1       1       205     1960
> 1       1       205     1961
> 1       1       205     1962
> 1       1       205     1963
> 1       1       205     1964
> 1       2       220     1965
> 1       2       220     1966
> ...
> 1       1       339     1960
> 1       1       339     1961
> etc.
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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