Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: generate


From   Mirriam Gee <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index