[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Jeph Herrin <junk@spandrel.net> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Placing a non-missing value at beginning of a block |

Date |
Wed, 10 Dec 2008 13:05:23 -0500 |

I'm a little confused because in the second set of data below, the -pvalues- have moved but the -n-s have not, which I think may not be what you want, but we'll do it anyway. gen group=_n sort n replace group=group[_n-1] if _n>1&!(mi(pvalue)&!mi(pvalue[_n-1])) this creates a variable -group- which is constant for each of your groups. Then, to shift the pvalue to the top of the group: bys group (n) : replace pvalue[1]=pvalue[_N] bys group (n) : replace pvalue[_N]=. hth, Jeph Thomas Speidel wrote:

I am trying to create a spreadsheet ready table from within Stata andneed to do some data management in order to go from this:n pvalue 1 . 2 . 3 . 4 . 5 0.151 6 . 7 . 8 . 9 . 10 0.000 11 . 12 . 13 . 14 . 15 0.146 16 . 17 . 18 . 19 . 20 . 21 0.001 ... To this: n pvalue 1 0.151 2 . 3 . 4 . 5 . 6 0.000 7 . 8 . 9 . 10 . 11 0.146 12 . 13 . 14 . 15 . 16 0.001 17 . 18 . 19 . 20 . 21 . ...Notice that the blocks are not constant (some are 5, some are 6 etc.-this is just a portion of the data-). My difficulty lies in the factthat there is no natural grouping variable. I tried a mixture ofsubscripting and sequence generating commands, but did not get too far.The crucial part is that I need to place the non-missing pvalue at thebeginning of the block, while right now it is at the end.

* * 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/

**Follow-Ups**:**Re: st: Placing a non-missing value at beginning of a block***From:*Thomas Speidel <thomas@tmbx.com>

**References**:**st: Placing a non-missing value at beginning of a block***From:*Thomas Speidel <thomas@tmbx.com>

- Prev by Date:
**st: RE: Placing a non-missing value at beginning of a block** - Next by Date:
**st: AW: Placing a non-missing value at beginning of a block** - Previous by thread:
**st: RE: RE: Placing a non-missing value at beginning of a block** - Next by thread:
**Re: st: Placing a non-missing value at beginning of a block** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |