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: "stacking" a variable ?


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: "stacking" a variable ?
Date   Mon, 2 Dec 2013 16:33:56 +0000

In this case you can go

replace q2 = q2[_n+3] in 1/3
drop in 4/L

More technique is shown by

clear
 input q1 q2
 2.05 .
 3.01 .
 0.75 .
 . 1.99
 . 1.86
 . 0.44
 end

egen id = seq(), to(3)
egen j = seq(), block(3)
replace q1 = q2 if missing(q1)
rename q1 q
drop q2
reshape wide q, i(id) j(j)

Nick
[email protected]


On 2 December 2013 16:03, Nick Bornschein <[email protected]> wrote:
> Hello,
>
> after some problems with my data, I have a final question to deal with them. Imagine the following example:
>
> clear
> input q1 q2
> 2.05 .
> 3.01 .
> 0.75 .
> . 1.99
> . 1.86
> . 0.44
> end
>
> How do I "move" column q2 upwards, so that finally 1.99 is in the same line as 2.05 in the first row, 1.86 is besides 3.01 and so on.
>
> Thanks a lot
> -Nick
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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