Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: using reshape / xpose


From   n j cox <[email protected]>
To   [email protected]
Subject   st: using reshape / xpose
Date   Mon, 11 Dec 2006 17:43:22 +0000

This isn't an -xpose-. -xpose- is for when variables
and observations are the wrong way round.

reshape wide v3 , i(ID) j(v2) string
renpfix v3

works for your data example.

The key questions are

1. What identifies what you want to be distinct
observations? Answer: -ID-. This is -i()-'s argument.

2. What identifies what you want to be distinct
variables after -reshape-? Answer: -v2-. This
is -j()-'s argument.

However, there is an assumption here that the
values of -v2- could all be legal variable names.
If not, you'll need to fix that.

Nick
[email protected]

Mingfeng Lin

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?

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index