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: Arranging variables across rows
From
samuel gyetvay <[email protected]>
To
[email protected]
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/