Statalist The Stata Listserver


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

st: Reshape Question


From   "Rijo John" <rmjohn@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Reshape Question
Date   Wed, 19 Apr 2006 18:24:05 +0530

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.

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