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]

From |
Nick Bornschein <nick.bornschein@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: "stacking" a variable ? |

Date |
Mon, 2 Dec 2013 20:12:06 +0100 |

Ok, thank you all. I will give that a try tomorrow. My real data "change" the column every 181 values, so q1 is in 1/181, q2 from 182/363 and so on..hop that will work... ;)) > Am 02.12.2013 um 18:08 schrieb Nick Cox <njcoxstata@gmail.com>: > > <> > > I am just underlining that [_n+3] does the loop for you. > > Nick > njcoxstata@gmail.com > > >> On 2 December 2013 16:51, Thomas, Anthony <anthony_h_thomas@brown.edu> wrote: >> sorry, thought you wanted to move observations from q1 to q2. The >> principle is the same though... >> >>> On Mon, Dec 2, 2013 at 11:35 AM, Nick Cox <njcoxstata@gmail.com> wrote: >>> An explicit loop is unnecessary, as >>> >>> replace q2 = q2[_n+3] in 1/3 >>> >>> encapsulates the loop. Subscripting should be familiar in terms of >>> e.g. [_n-1] for previous observation. >>> >>> Nick >>> njcoxstata@gmail.com >>> >>> >>>> On 2 December 2013 16:28, Thomas, Anthony <anthony_h_thomas@brown.edu> wrote: >>>> Hi Nick, >>>> >>>> You can try using Stata's subscript notation "_n": >>>> >>>> replace q2 = q1[4] if _n == 1 >>>> replace q2 = q1[5] if _n == 2 >>>> >>>> *** where 4 and 5 are the observation number of what you want to move in q1 >>>> >>>> and so on. Of course it would be smarter to implement this in a loop >>>> if possible. >>>> >>>> Hope that helps, >>>> >>>> Anthony >>>> >>>> On Mon, Dec 2, 2013 at 11:03 AM, Nick Bornschein >>>> <nick.bornschein@gmail.com> 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/ >>> * >>> * 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/ > * > * 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/

**Follow-Ups**:**Re: st: "stacking" a variable ?***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: "stacking" a variable ?***From:*Nick Bornschein <nick.bornschein@gmail.com>

**Re: st: "stacking" a variable ?***From:*"Thomas, Anthony" <anthony_h_thomas@brown.edu>

**Re: st: "stacking" a variable ?***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: "stacking" a variable ?***From:*"Thomas, Anthony" <anthony_h_thomas@brown.edu>

**Re: st: "stacking" a variable ?***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**re: st: Dose-response analysis** - Next by Date:
**Re: st: "stacking" a variable ?** - Previous by thread:
**Re: st: "stacking" a variable ?** - Next by thread:
**Re: st: "stacking" a variable ?** - Index(es):