SAS programming for spatial problems (page 1)

N. Yiannakoulias (last update 2006-08-14)
IMPORTANT WARNING: I make no promises about the reliability or accuracy of any of this code. Feel free to use it at your own risk.

Here is some SAS code that applies the Besag and Newell (1991) approach. The test data are the New York Leukaemia data. Check out the references here.
Download the code
This is some work-in progress. It's code that calculates Moran's I measure of global spatial autocorrelation as well as a local (LISA) measure of spatial autocorrelation. The output is a bit of a mess, and there is no inferential component quite yet. However, the code uses SAS/IML, and so it's easy to modify even if you're not a SAS user.
Download the code
This is code for Tango's (1995) test for general clustering based on weight calculations by Rogerson (1999). I translated this code from the R language version authored by Waller and Gotway (2004). Check out the references here.
Download the code
This is a kernel smoother useful for visualizing patterns in point data. This example uses John Snow's study of cholera in London. On the left are cholera deaths (black points) and the 19th century London water pumps (red points). The kernel calculates the density of deaths, and gives a general indication of where the density is highest. SAS is hardly the best environment for performing raster GIS operations, but as can be seen here, it's possible.
Download the code the cholera data & the pump data
This is an exploratory tool useful for detecting hotspots of crime and disease. I write 'exploratory' since there are no statistical evaluation criteria embedded here. The method is loosely based on the work of Rushton and Lolonis (1996) (reference list) in which a moving window passes over point data to smooth out local variability. Essentially, a kernel smoother.
Download the code
This program is an example of how easy it is to move from SAS to a true GIS environment. The structure of SAS map polygons is very similar to the structure of MapInfo .mif files. Its really easy to write SAS map file with the format rules of .mif. To use the .mid file, you have to dynamically modify the number of columns. One day I may streamline this, but it's a start. The map below was generated in Manifold, my favourite GIS environment. Note the elongated shapes--I was lazy, and used Euclidean distance on unprojected data!
Download the code
This code detects global clusters using the Cuzick & Edwards (1990) approach (reference list). Essentially, it determines whether cases occur near each other more often than you'd expect by chance alone. The method as applied here does not tell us where the cluster is, however. The default data are random, but it's easy to modify the code to support your data.
Download the code
Another old-style cluster detection method. It was developed by Turnbull et al. (1990) (reference list) and inspired a number of other methods that are in use today. This can be used to detect disease or crime hot-spots--you need a numerator and denominator. The data included are simulated, but once again, it's easy enough to modify.
Download the code
The code here is short and sweet. It can be used to simulate spatially dependent behaviour--like the spread of infectious disease. This simulation assumes an homogenous population density (well, it actually ignores population) and spawns 'disease' based on some user settings. You can also introduce a bias (or trend) in the direction of disease growth so it spreads into conic-like plumes. Oh yeah!
Download the code Download a small animation (375 Kb)
This program is an improvement on the above example. It uses a Huff spatial interaction model to define how the automatons interact. Essentially, closer people are more likely to interact. If a 'sick' automaton interacts with a non-sick automaton (who isn't already immune to disease) the disease transmits with a probability specified by the user. There are a number of settings you can play with-- shedding (how long an automaton is infectious) survival (how long an automaton can live with the disease before death) and how long a survivor is immune to a repeat infection.

The graphic shows how the transmission model progresses over time under the default settings. The y-axis is cases of disease, the x-axis is time.

Download the code

Back to main page (Go to page 2 ) (Go to page 3 ) (Go to page 4 ) (Go to page 5 )