Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: how to transform variables again!


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: how to transform variables again!
Date   Tue, 15 Nov 2011 12:48:07 +0000

Answers were implied in both of the previous answers by Daniel Klein and myself. 

gen group1 = var1[1]
gen group2 = var2[1] 
drop in 1 
reshape long var group , i(code)
sort group code 

Now that you know that your problems are -reshape- after a little preparation, the next one is set as an exercise. 

Nick 
n.j.cox@durham.ac.uk 

econqian

      How to transform the original format of two variables to the new
format of two variables?
Original format
code	Var1	Var2
	4	8
1	54	89
2	87	28
3	39	75
4	99	96
5	119	100

New format
code	Va1	Var2
1	54	4
2	87	4
3	39	4
4	99	4
5	119	4
1	89	8
2	28	8
3	75	8
4	96	8
5	100	8


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index