Statalist The Stata Listserver


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

st: RE: Reshape Question


From   "David Harrison" <david.harrison@icnarc.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Reshape Question
Date   Wed, 19 Apr 2006 14:03:04 +0100

To make sure you get the variable names you want at the end...

rename code j
rename value code

Then this is just:

reshape wide code, i(ID) j(j)

Hope this helps

David

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Rijo John
Sent: 19 April 2006 13:54
To: statalist@hsphsun2.harvard.edu
Subject: st: Reshape Question

hi all,

can anyone help me reshape my data in the following way?

Currently my data is in the following format:

ID 	code 	value 	var1 	var2
1 	110 	10 	5 	8
1 	111 	30 	5 	8
1 	115 	25 	5 	8
2 	110 	28 	3 	6
2 	111 	21 	3 	6
3 	115 	32 	7 	6
4 	110 	23 	9 	4
4 	111 	45 	9 	4
4 	115 	65 	9 	4

and I want to convert it into

ID  code110  code111 code115   var1    var2
1 	10 	  30 	       25 	    5 	     8
2 	28 	  21 	        . 	     3 	       6
3 	. 	    . 	         32 	       7 	6
4 	. 	   45 	        65 	     9        4

The codes reshaped from long to wide format and the values for each
codes are taken from the variable "value". Hence the variable "value"
disappears and new variables "code110 code111 code115" appears.  var1
and var2 are same for each codes in a particular ID.

I am not able to figure out how to reshape it.

Regards,
John.

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index