Bookmark and Share

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]

Re: st: correction: how to stack some variables and duplicate others


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: correction: how to stack some variables and duplicate others
Date   Wed, 9 Mar 2011 10:35:48 -0600

clear
input 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
end

rename num015 num1515
reshape long m1_ m2_ m3_  num15,i(house)
rename num15 ptnum
renvars m*, postdrop(1)
drop _j
l

Using -renvars- by Jeroen Weesie and Nick Cox (-findit renvars- to
locate and download).

Scott


On Wed, Mar 9, 2011 at 10:20 AM, Mariano Matias Iberico
<[email protected]> wrote:
> Sorry, I didn't take into account spaces in plaintext.  Here is a better
> version.
> 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 –expand–ptnum.  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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index