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: how to stack some variables and duplicate others
From
Mariano Matias Iberico <[email protected]>
To
statalist <[email protected]>
Subject
st: how to stack some variables and duplicate others
Date
Wed, 09 Mar 2011 10:19:25 -0500
Dear all,
I am looking at data on adherence to 3 month treatment.
I have data on households that have been grouped into two categories by
age 0-15 and 15-18 the dataset looks roughly like this
houseID num015 m1_15 m2_15 m3_15 num1518 m1_18 m2_18 m3_18 income edu
1 5 4 3 3 4 4 4 0 100 1
2 2 2 2 1 0 0 0 0 110 2
3 0 0 0 0 1 1 1 1 1000 6
. . .
I would like to -stack-num015-m3_18, into(ptnum m1 m2 m3)
When I do this I loose the income and edu data, which I would like to
duplicate as shown below.
houseID ptnum m1 m2 m3 income edu _stack
1 5 4 3 3 100 1 1
1 4 4 4 0 100 1 2
2 2 2 2 1 110 2 1
2 0 0 0 0 110 2 2
3 0 0 0 0 1000 6 1
3 1 1 1 1 1000 6 2
. . .
The next step for this is an -expand-ptnum, and then I have a code written
to change m1-m3 into dummy variables to see how far along each pt of each
age got in the treatment.
Any suggestions are welcome as I have been banging my head against the
wall with this one for some time!
Regards,
Matias
*
* 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/