Statalist The Stata Listserver


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

Re: st: constructing an unbalanced panel data set based on existingrange variables


From   Ronnie Babigumira <rb.glists@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: constructing an unbalanced panel data set based on existingrange variables
Date   Wed, 29 Mar 2006 17:38:05 +0200

A long shot (I'm am assuming here that IDyear is from both Start and End)
------------------- begin ------------------------------
clear
input ID      Start      End      Industry
1       1985       1990        3
2       1988       1991        1
3       1982       1993        3
end

rename Start year1 //Ofcourse if u have more variables, you can make this more efficient
rename End year2
reshape long year, i(ID) j(string)

// I would then change ID and year to string. This allows us to concatenate these two variables
tostring ID, replace
tostring year, replace

egen IDyear = concat(ID year)
order IDyear
keep IDyear Industry
list

---------------end-----------------------------------------------

Arik wrote:
Hi, I have a list of observations by unit (firm),
which I would like to transfrom into a panle data set,
by year/unit.

Right now, the first variables of the observations
look something like

ID Start End Industry
1 1985 1990 3
2 1988 1991 1
3 1982 1993 3

And I'd like them to look like

IDyear Industry
11985 3
11986 3 11987 3
11988 3
11989 3
11990 3
21988 1
21989 1
21990 1
21991 1
31982 3
31983 3
...
31993 3

Reshape does not seem to help, as I have a
(unbalnaced) range, rather then a fixed list of
variables. Any ideas, what I can do?

Cheers,
Arik

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com *
* 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/



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