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 on April 23, and its replacement, statalist.org is already up and running.


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

st: generate


From   Mirriam Gee <mirrgee@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: generate
Date   Wed, 6 Oct 2010 12:01:05 -0700

Hi all,

Let me use a simple example to ask my question. Lets say i have the
following data showing hid (household identifier), and variable g1-
g200 as follows:
hid       g1                      g2                    g3
           g4                           g5.........................
111         2                      0                      0
              4
1.............................
112         0                      0                      1
              3
2.............................
113         1                      4                      1
              0
3............................
114          0                     0                      1
              2
2............................
............
....up to 30000 households

How can I generate new variable(s) X1- X20 which contains the first 20
numbers ( excluding the zeros) from g1- g100?. For example:

hid              X1                    X2                        X3
............................
111             2                      4                          1
.............................
112             1                      3                           2
............................
113             1                      4                           1
.............................
114             1                      2
2...............................
......
....

Thank you in advance for your assistance...


Kind Regards

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