Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Data Expansion Question


From   "Scott Merryman" <[email protected]>
To   [email protected]
Subject   Re: st: Data Expansion Question
Date   Thu, 31 Jan 2008 11:12:20 -0600

Take a look at -expand-

For example:

clear
input id    duration     count      year
1                            4          1         1990
2                            3          1         1995
end
expand dur
bysort id: replace year = year +_n -1
by id: replace count = _n
l , sepby(id)


Scott

On Jan 31, 2008 10:58 AM, Lektzian, David <[email protected]> wrote:
> Dear Statalist,
> I have a question regarding the expansion of a cross-sectional
> time-series dataset that I am working with.  Basically, I have cases
> with an indicator of the duration of the case in years.  I would like to
> expand this data out so that there is a separate observation for each
> year that the case existed.  I would also like to include a count of
> which year the case is in, and a year variable tracking the year.  Could
> anybody help me with the creation of a simple do file that would expand
> the data?
*
*   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