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

st: Anti-collapsing time series data


From   Johnathan Boysielal <[email protected]>
To   [email protected]
Subject   st: Anti-collapsing time series data
Date   Mon, 02 May 2005 13:05:51 -0400

Hello,

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.

Perhaps one of you who has done this many times before can help me out?

Thanks very much,
Johnathan

*
* 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