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: Data Management Loop


From   Toby <spiegeldesaster@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Data Management Loop
Date   Fri, 1 Apr 2011 20:14:16 +0200

Hello Statalist,

i have a problem with the following data structure:

id type   x
1 1       1
2 2       2
3 1       3
4 2       4
5 1       5
6 2       6

Now I want to generate additional variables that include the x value
for the opposite type, so that the data looks like this:

id type   x   x_2   x_4    x_6   x_1    x_3   x_5
1 1       1    2      4        6
2 2       2    .       .        .         1     3         5
3 1       3    2     4         6
4 2       4    .       .        .         1     3         5
5 1       5    2     4         6
6 2       6    .       .        .         1     3         5

Until know I only have created a loop that generates this additional
variables, but I did not figured out how to disriminate between the
two type. Can anyone hive me a hint?

Kind regards,
Toby.
*
*   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