Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Converting the values of a variable into variables


From   "Carlos de Los Rios" <[email protected]>
To   <[email protected]>
Subject   st: RE: Converting the values of a variable into variables
Date   Thu, 24 Nov 2005 13:46:00 -0500

Hi,

Try first encoding the datadefinition variable by:

encode datadefinition, g(name)

Following try reshape:

reshape wide datavalue, i(id) j(name)

afterwards, you may want to rename your variables:

ren datavalue1 income
ren datavalue2 age
ren datavalue3 weight

Hope its useful!

Carlos DLR

-----Mensaje original-----
De: [email protected]
[mailto:[email protected]] En nombre de
[email protected]
Enviado el: Jueves, 24 de Noviembre de 2005 01:32 p.m.
Para: [email protected]
Asunto: st: Converting the values of a variable into variables

Hi,

I have a data set of the form:

id datadefiniton datavalue
1   income          1000
1   age               64
1   weight           125
2   income          1500
2   age               44
2   weight           165

which I want to convert to the form:

id income age weight 
1   1000    64   125
2   1500    44   165

Any suggestions would be most welcome!

Thanks.

Steve

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



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