Raphael Fraser wrote:
How does one get from dataset1 to dataset2?
DATASET1
x y
1 .
2 .
3 .
. 4
. 5
. 6
DATASET2
x y
1 4
2 5
3 6
--------------------------------------------------------------------------------
For a general solution, see -help stack-.
Joseph Coveney
clear
set more off
input byte x byte y
1 .
2 .
3 .
. 4
. 5
. 6
end
*
* Begin here
*
stack x y, into(a)
generate long row = _n
drop if missing(a)
bysort _stack (row): replace row = _n
reshape wide a, i(row) j(_stack) // You're actually done here.
drop row
rename a1 x
rename a2 y
list, noobs sep(0)
exit
*
* 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/