| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: RE: Problem with "reshape"
This may work:
forvalues i = 1(1)300 {
foreach XY in x y {
rename code`i'_var`XY' var`XY'_`i'
}
}
reshape long varx_ vary_, i(date) j(code)
rename varx_ varx
rename vary_ vary
You may need to make use of capture, in case your individuals are not
consecutievely numbered.
HTH,
Philipp
Riano, Juanita wrote:
Thanks Justin, but 'stack' doesn't work because I need to preserve the
individuals' code.
Juanita
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of White, Justin
Sent: Wednesday, October 04, 2006 11:47 AM
To: [email protected]
Subject: st: RE: Problem with "reshape"
Try the 'stack' command
Justin White
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Riano,
Juanita
Sent: Wednesday, October 04, 2006 11:43 AM
To: [email protected]
Subject: st: Problem with "reshape"
Dear all,
I have a wide dataset organized as follows
date code1_varx code1_vary code2_varx code2_vary
1990 10 20 10 30
1991 10 20 10 30
...
Where: code1- code300 identify individuals and varx vary are the
varnames (I have 9 variables).
What I want is a long dataset that looks like this
date code varx vary
1990 1 10 20
1991 1 10 20
..
1990 2 10 30
1991 2 10 30
..
Using the reshape command hasn't worked for me so far because the stub
that identifies the name of the variable is at the end of it:
no xij variables found r(111);
I also tried to transpose the data using the "xpose" command to
manipulate the names but when you use "xpose" twice the string variables
are dropped,,,
I would really appreciate any suggestion on how to proceed,,,
Thank you very much,
Juanita Riano
*
* 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/
*
* 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/