Statalist


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

Re: st: reorganize data


From   Philipp Rehm <[email protected]>
To   [email protected]
Subject   Re: st: reorganize data
Date   Mon, 31 Dec 2007 14:23:06 +0100

How about this?

clear
input ID     BirthYearOfChild
2         1973
2         1975
3         1954
4         1965
4         1967
4        1969
end

bys ID (BirthYearOfChild): gen id=_n

reshape wide BirthYearOfChild, i(ID) j(id)

HTH,
Philipp


[email protected] wrote:
Hello,

I am a STATA-beginner, but since I need it for my diploma, I am forced to send you a question.
My data is organized as follows... for example:

ID BirthYearOfChild
2 1973
2 1975
3 1954
4 1965
4 1967
4 1969

My problem is, that the identifyers appear more than once. I want to restructure the data to get it into the
form:

ID BirthYearOfFirstChild BirthYearOfSecondChild BirthYearofThirdChild
2 1973 1975 .
3 1954 . .
4 1965 1967 1969

I tried with some If and ForEach and ForValues commands, but they all don�t work. I would be really very grateful if anyone could give me an advice how to reorganize the data.

Thank you all for reading,
Markus.




*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index