Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: insert obs of one file at the beginning of another file


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: insert obs of one file at the beginning of another file
Date   Fri, 22 Nov 2002 20:03:19 -0000

This should be something more like

gen long which = cond((_N - _n) < 10, _n - _N, _n)
sort which

Nick
n.j.cox@durham.ac.uk

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox
> Sent: 22 November 2002 19:23
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: insert obs of one file at the beginning of
> another file
>
>
> Daniel Müller
> >
> > I would like to insert observations (format: %12s) of one
> > variable of a file with 10 obs <head.dta> at the beginning
> > of several variables (converted to strings) of another file
> > <boss.dta> and shift the remaining observations from
> > <boss.dta> these 10 obs back. I appended <head.dta> to
> > <boss.dta>, then replaced every empty observation at the end
> > of <boss.dta>. But here I get stuck. How can I efficiently
> > put the string variables from the end to the beginning?
> >
> > P.S.: Speed is an issue as <boss.dta> has 1.7 mio obs!
>
>
> In the last sentence, Daniel means "observations" not
> variables (pers.comm.).
>
> gen long which = cond(_n <= 10, _N + _n, _n)
> sort which
>
> Nick
> n.j.cox@durham.ac.uk
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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