Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: RE: how to transform variables
From 
 
"Qian Yu" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
st: RE: RE: how to transform variables 
Date 
 
Tue, 15 Nov 2011 13:39:20 +0100 
Hi, nick
   Thanks for your kind help!
Best
Qian
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 15 November 2011 13:14
To: '[email protected]'
Subject: st: RE: how to transform variables
input var1	var2
4	8
54	89
87	28
39	75
99	96
119	100
end
gen group1 = var1[1]
gen group2 = var2[1] 
drop in 1 
gen id = _n
reshape long var group , i(id)
sort group id
. l
     +-----------------------+
     | id   _j   var   group |
     |-----------------------|
  1. |  1    1    54       4 |
  2. |  2    1    87       4 |
  3. |  3    1    39       4 |
  4. |  4    1    99       4 |
  5. |  5    1   119       4 |
     |-----------------------|
  6. |  1    2    89       8 |
  7. |  2    2    28       8 |
  8. |  3    2    75       8 |
  9. |  4    2    96       8 |
 10. |  5    2   100       8 |
     +-----------------------+
Nick 
[email protected] 
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of econqian
Sent: 15 November 2011 11:38
To: [email protected]
Subject: st: how to transform variables
Hi, all
      How to transform the original format of two variables to the new
format of two variables?
Original format
Var1	Var2
4	8
54	89
87	28
39	75
99	96
119	100
New format
Va1	Var2
54	4
87	4
39	4
99	4
119	4
89	8
28	8
75	8
96	8
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/
*
*   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/