Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: looping over observations in a single variable


From   Abhimanyu Arora <abhimanyu.arora1987@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: looping over observations in a single variable
Date   Mon, 12 Jul 2010 19:48:28 +0200

One strategy could be to use -duplicates drop-  and making use of
[_n+1] or [_n-1] in the -if- option.

On Mon, Jul 12, 2010 at 7:36 PM, Casey P. Durand <durandca@usc.edu> wrote:
> Hi folks,
>
> I'm trying to figure out how to loop over sets of observations within
> a single variable.  Basically, I've got a variable which contains
> dates.  There are about 15 observations with one date, then another 15
> with the next days date, and so on, for a total of about 7 days.  Each
> individual observation also contains two other variables with GPS
> coordinates in them.   However, in some cases, some dates were copied
> and pasted in between other dates, creating some interruptions in the
> data.  I'm attempting to find a way to ID those inserted segments.  To
> visually describe this, a generic example would be something like
> this:
>
> Var1
> ------
> Z1
> Z1
> Z2
> Z2
> Z3
> Z3
> Z1
> Z1
> Z4
> Z4
>
> In this example, the parts I want to flag and, if possible, delete,
> are the Z1s between the Z3s and Z4s.
>
> I'm having a tough time doing this for observations within a single
> variable.  Does anyone know how to do this in Stata?
>
> Thanks in advance,
>
> Casey
> *
> *   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/
>

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


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