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

Re: st: recoding variables


From   [email protected]
To   [email protected]
Subject   Re: st: recoding variables
Date   Wed, 8 Oct 2003 13:31:43 -0700

Thanks,

Works great.

Jim


                                                                                                                               
                    "Dimitriy V. Masterov"                                                                                     
                    <[email protected]       To:     [email protected]                                    
                    o.edu>                           cc:                                                                       
                    Sent by:                         Subject:     Re: st: recoding variables                                   
                    [email protected]                                                                                 
                    arvard.edu                                                                                                 
                                                                                                                               
                                                                                                                               
                    10/08/2003 10:10 AM                                                                                        
                    Please respond to                                                                                          
                    statalist                                                                                                  
                                                                                                                               
                                                                                                                               




There is a very quick way to do this. Let's say you have data like this:
id               x1                x2                   x3
x4
1          .1369841       .2551499        .2769154            .7152805
2          .6432207       .0445188        .1180158            .699069
3          .5578017       .4241557        .4079702            .2322688
4          .6047949       .8983462        .7219492            .0981878
5          .684176                .5219247          .871691
.5948404
6          .1086679       .8414094        .4611429            .3533874
7          .6184582       .2110077        .4216726            .8071709
8          .0610638       .5644092        .8944746            .1024369
9          .5552388       .2648021        .0580662            .5773884
10         .8714491       .9477426        .6759487            .1091783

The command

reshape long x, i(id) j(year)

will create a variable called x that will contain the score and a new
variable called year that will be the number i from xi.

Your data will now look like this:

id         year           x
1          1         .9746088
1          2         .0907986
1          3         .8953723
1          4         .0871481
2          1         .216239
2          2         .8165695
2          3         .4854506
2          4         .3840067
3          1         .2610746
3          2         .2655343
3          3         .2273252
3          4         .0460549
4          1         .1650207
4          2         .4528397
4          3         .9375801
4          4         .8091199
5          1         .760604
5          2         .131106
5          3         .8948932
5          4         .4121684
6          1         .3713805
6          2         .2255593
6          3         .8602547
6          4         .5049801
7          1         .3795409
7          2         .0369273
7          3         .1909852
7          4         .3695011
8          1         .9678735
8          2         .1718031
8          3         .6267227
8          4         .2908498
9          1         .5823284
9          2         .290384
9          3         .7391482
9          4         .414847
10         1         .7952999
10         2         .628377
10         3         .541567
10         4         .1966634

Dimitriy Masterov

_______________________________________________________________________________

Dimitriy V. Masterov

Work:
Center for Social Program Evaluation
1155 East 60th St. Room 038
Chicago, IL 60637
Work: (773)256-6005
Fax: (773)256-6313

Home:
1312 East 53rd St., Apt.309
Chicago, IL 60615
Mobile: (773)220-2760


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