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

From |
Thomas Speidel <thomas@tmbx.com> |

To |
statalist@hsphsun2.harvard.edu |

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

Date |
Wed, 10 Dec 2008 11:57:36 -0700 |

Many thanks to all who contributed! Quoting Jeph Herrin <junk@spandrel.net> Wed Dec 10 11:05:23 2008:

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 Stataand need 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 thefact that there is no natural grouping variable. I tried a mixtureof subscripting and sequence generating commands, but did not gettoo far. The crucial part is that I need to place the non-missingpvalue at the beginning of the block, while right now it is at theend.* * 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/

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

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

**Re: st: Placing a non-missing value at beginning of a block***From:*Jeph Herrin <junk@spandrel.net>

- Prev by Date:
**st: re: newey west** - Next by Date:
**st: Displaying full independent variable names in regression commands** - Previous by thread:
**Re: st: Placing a non-missing value at beginning of a block** - Next by thread:
**st: AW: Placing a non-missing value at beginning of a block** - Index(es):

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