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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: looping over observations in a single variable


From   "Casey P. Durand" <durandca@usc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: looping over observations in a single variable
Date   Mon, 12 Jul 2010 12:36:22 -0500

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/


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