clear
input ID str4 v2 v3
1 abc 99
1 dce 812
1 kdje 282
2 abc 33
2 dce 221
2 kdje 772
end
reshape wide v3, i(ID) j(v2) string
renpfix v3
. list
+-----------------------+
| ID abc dce kdje |
|-----------------------|
1. | 1 99 812 282 |
2. | 2 33 221 772 |
+-----------------------+
HTH,
Philipp
Mingfeng Lin wrote:
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/