Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Loop to determine values of a variable based on values of variables |
Date | Sat, 17 Aug 2013 17:42:17 +0100 |
See the FAQ http://www.stata.com/support/faqs/data-management/neighbors-on-rectangular-grid/ Nick njcoxstata@gmail.com On 17 August 2013 17:21, Rainer zu Fall <kthulhuforpresident@googlemail.com> wrote: > The observations in my data are grid-years. A grid is a roughly > quadratic spatial unit. I have a variable denoting whether or not a > conflict is going on in a grid. However, I want to know whether > conflicts are going on in nearby grids, too. > > I can identify nearby grids by their values on the variables "row" and > "column"- any grid with values deviating from the values of my grid of > interest no more than one unit on both variables are adjacent. > > My aim would be to create a dummy variable adjacentconflict=1 if > conflict==1 in any of the adjacent grids. > I reckon I have to write a loop to do this. I have tried around a bit, > but seem to be at a loss. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/