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: correction2: how to stack some variables and duplicate others
From
Mariano Matias Iberico <[email protected]>
To
statalist <[email protected]>
Subject
st: correction2: how to stack some variables and duplicate others
Date
Wed, 09 Mar 2011 11:26:45 -0500
OK, It think I finally got it right. Sorry.
I am looking at data similar to 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
. . .
I tried -reshape but can't get it to work either.
The next step for this is to -rename- and -label-_stack into an age
variable and expandptnum. 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/