| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: using reshape / xpose
I tried this code and it seemed to work:
reshape wide var3, i(var1) j(var2) string
Here is the result set:
var1 var3abc var3dce var3kdje
1 99 812 282
2 33 221 772
However, you will have to figure out a loop that will go through and
rename the variables (that will strip out the var3 part of the name and
leave the remaining)
HTH
Justin White
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mingfeng Lin
Sent: Monday, December 11, 2006 12:22 PM
To: [email protected]
Subject: st: using reshape / xpose
This might actually be a very simple question but I still couldn't
figure out after I tried the reference and the Statalist archive. I
have a dataset that looks like this:
ID v2 v3
1 abc 99
1 dce 812
1 kdje 282
2 abc 33
2 dce 221
2 kdje 772
....
And I am trying to change it into this format:
ID abc dce kdje
1 99 812 282
2 33 221 772
....
There are over 1000 variables for each ID (those like abc, dce, kdje
in the example above), and I would really like to keep the original
variable names. I also tried -xpose-, but then the variable names
(like abc, dce, kdje) became missing in the new dataset. Is there a
quick way to do this?
Thanks very much for your help!
Mingfeng
*
* 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/