Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Reshape problem


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Reshape problem
Date   Thu, 3 Nov 2011 12:35:58 +0000

This is still a -reshape long-. (Some people talk about "long long".) Looks like 

reshape long V, i(Unit Time) <etc.> 

followed by clean-up as appropriate. 

There is discussion within 

http://www.stata.com/support/faqs/data/reshape3.html

Nick 
n.j.cox@durham.ac.uk 

Johan Hellström

I have a dataset that is in long form (containing a lot of variables), but some variables (v1-v34 in the example below) are measured at a different level and stored in wide form. That is, it is the same variable for different sub-units.  These also contain a lot of empty cells. Does anyone know a way to create a new panel where all "wide form"-variables (V1-V34) is coverted into long form (and the values stored in a 'New-variable'). The example below gives an indication of how my dataset looks like. For each 'Unit' it is about 10-25 measurement points over time (unbalanced panel). 

Old panel:
----------------------------------------------------------------------------------------------------------------------------------------------------
Unit	Time	x1	V1	V2	V3	V4	...	v34
1	1	12.3	.	67	26	48	...	23
1	2	26.6	45	34	12	.	...	64

...

2	1	84.0	83	.	.	23	...	87
2	2	23.5	.	.	91	82	...	98

...
----------------------------------------------------------------------------------------------------------------------------------------------------


New panel:
-----------------------------------------------------------------------------------------------------
Unit	Sub-unit	Time	x1	New-variable
1	1	1	12.3	.
1	2	1	12.3	67
1	3	1	12.3	26
1	4	1	12.3	48
...
1	34	1	12.3	23
1	1	2	26.6	45
1	2	2	26.6	34
1	3	2	26.6	12
1	4	2	26.6	.
...

2	1	1	84.0	83
2	2	1	84.0	.
2	3	1	84.0	.
2	4	1	84.0	23
...
2	34	1	84.0	87
2	1	2	23.5	83

Etc.
------------------------------------------------------------------------------------------------------	


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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index