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: Arranging variables across rows


From   samuel gyetvay <sam.gyetvay@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Arranging variables across rows
Date   Tue, 26 Jun 2012 17:37:23 -0400

I have two sets of variables, let's call them A1, A2, ... A19 and B1,
B2, ... B8.

A1, A2, ... A19 give identification numbers for up to 19 individuals
per family. Each family occupies a row in the data set.

B1, B2, ... B8 list identification numbers of up to 8 individuals who
have received treatment.

I need to preserve the order and placement of variables in A1, ... A19
and would like to create a dummy variable equal to 1 whenever an
individual has received treatment. Basically, I need to go from
something that like this:

A1  A2  A3 ...  A19
101 102 103 ... 19

B1 B2 B3 ... B8
103  .    .    ...  .

To something like this

A1  A2  A3 ...   A19
101 102 103 ... 119

D1 D2 D3 ... D19
0   0    1   ... 0

I am aware of the command rowsort, but it does not solve this
particular problem. rowsort would turn

B1 B2 B3 ... B8
.      .  102 ...  .

 into

B1 B2 B3 ... B8
102 .   .    ...  .

when what I need is

B1 B2 B3 ... B8
.    102  .  ...  .

I could create a dummy variable equal to 1 when A is equal to B


Hopefully this question is clearly phrased, and there exists a simple
solution. Please let me know if you have any suggestions or if
anything is unclear.

Thank you,

-S

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