Thanks, Scott. That was exactly what I needed. The only thing I was
not sure of was the purpose of the last line 1, sepby(id). I ran that
line, and the data looks fine. I just was not sure of what that line
did.
David
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Scott
Merryman
Sent: Thursday, January 31, 2008 11:12 AM
To: [email protected]
Subject: Re: st: Data Expansion Question
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/
*
* 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/