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

st: Anti-collapsing time series data


From   Arnold Layne <[email protected]>
To   [email protected]
Subject   st: Anti-collapsing time series data
Date   Mon, 2 May 2005 12:38:59 -0400

Hello,

I have cross-sectional time series data 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 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 give me a hint?

Thanks very much,
Arnold.

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