# SAS/STAT Spatial Analysis – 4 Important Procedures

In our last tutorial, we studied SAS survival analysis Procedure. Here, we will discuss SAS/STAT Spatial Analysis. We will also learn important procedures used in Spatial Analysis in SAS/STAT: PROC KRIGE2D, PROC SIM2D, PROC SPP, and PROC VARIOGRAM with Syntax & Examples.

So, let’s start SAS/STAT Spatial Analysis.

### What is SAS/STAT Spatial Analysis?

Like other processes, SAS Spatial analysis also turns raw data into useful information. The basic motive behind SAS/STAT spatial data analysis is to derive useful insights from real-world phenomena such as crimes, natural disasters, mining of ores, vegetation, and so by making use of their location and context.

You will always find spatial analysts very curious as to why things happen, how they happen, where they do. They are also curious about the effect of those phenomena on nearby regions. A spatial analysis in SAS/STAT finds its application in various fields such as agriculture, public health, insurance, forestry, crime analysis, environmental monitoring, and, energy.

### Procedures for Spatial Analysis in SAS/STAT

Following procedures use to compute SAS/STAT spatial analysis of a sample data. Let us explore it.

#### a. PROC KRIGE2D

SAS PROC KRIGE2D performs spatial prediction of any spatial point reference data. The basic function is kriging, kriging is a procedure that generates estimates of a particular surface by making use of a scattered set of points that have z-values.

It has a grid statement where we specify the locations of kriging predictions. The output data set has both the kriging predictions and the standard errors associated with the data.

A Syntax of PROC KRIGE2D-

```PROC krige2d DATASET<options>;
COORDINATES | COORDÂ coordinate-variables;
GRID grid-options;
PREDICT | PRED | P predict-options;
MODELÂ model-options;```

PROC KRIGE2D Example-

```ods graphics on;Â
proc krige2d data=sashelp.iris plots=all;
Â Â  coordinates xcoord=sepallength ycoord=sepalwidth;
Â Â  model scale=7.4599 range=30.1111 form=gauss;
Â Â  grid x=0 to 100 by 2.5 y=0 to 100 by 2.5;Â
run;```

The PROC PREDICT, KRIGE2D and the MODEL statement is required and you provide the prediction parameters in theÂ PREDICT statement.
The coordinates of the variable are specified in theÂ COORDINATESÂ statement.
TheÂ MODEL statement contains the parameters that describe your data spatial correlation. Namely, theÂ FORM=Â option specifies the model type say Gaussian, exponential etc, based on its mathematical form.
TheÂ SCALE=Â andÂ RANGE=options specify the model scale on which we want the data to be analyzed and range, respectively.
The region of predictions is specified with theÂ GRID statement.

SAS/STAT Spatial Analysis –Â PROC KRIGE2D

SAS/STAT Spatial Analysis –Â PROC KRIGE2D

SAS/STAT Spatial Analysis –Â PROC KRIGE2D

#### b. PROC SIM2D

The SIM2D procedure in SAS/STAT spatial analysis alsoÂ produces a spatial simulation but for a Gaussian field. It uses a decomposition technique to also specify mean and covariance structure in two dimensions. The most important feature is that it enables you to specify the covariance and the mean structure by naming the form.

The locations of the simulation points that are specified in the grid statement are also available with this procedure just like the krige2d procedure.

A Syntax of PROC SIM2D-

```PROC SIM2D DATASET<options>;
SIMULATE simulate-options;
MEANÂ mean-options;Â
COORDINATES | COORDÂ coordinate-variables;Â
GRID grid-options;```

TheÂ PROC SIM2D and SIMULATE statement is required.

PROC SIM2D Example-

```title 'finding sugar content in chocolates Using PROC SIM2D for Spatial Simulation';
data chocolates;
Â Â  input munch kitkat gems @@;
Â Â  datalines;
Â Â Â  0.7Â  59.6Â  34.1Â Â  2.1Â  82.7Â  42.2Â Â  4.7Â  75.1Â  39.5
Â Â Â  4.8Â  52.8Â  34.3Â Â  5.9Â  67.1Â  37.0Â Â  6.0Â  35.7Â  35.9
Â Â Â  6.4Â  33.7Â  36.4Â Â  7.0Â  46.7Â  34.6Â Â  8.2Â  40.1Â  35.4
Â Â  13.3Â Â  0.6Â  44.7Â  13.3Â  68.2Â  37.8Â  13.4Â  31.3Â  37.8
Â Â  17.8Â Â  6.9Â  43.9Â  20.1Â  66.3 Â 37.7Â  22.7Â  87.6Â  42.8
Â Â  23.0Â  93.9Â  43.6Â  24.3Â  73.0Â  39.3Â  24.8Â  15.1Â  42.3
Â Â  24.8Â  26.3Â  39.7Â  26.4Â  58.0Â  36.9Â  26.9Â  65.0Â  37.8
Â Â  27.7Â  83.3Â  41.8Â  27.9Â  90.8Â  43.3Â  29.1Â  47.9Â  36.7
Â Â  29.5Â  89.4Â  43.0Â  30.1Â Â  6.1Â  43.6Â  30.8Â  12.1Â  42.8
Â Â  32.7 Â 40.2Â  37.5Â  34.8Â Â  8.1Â  43.3Â  35.3Â  32.0Â  38.8
Â Â  37.0Â  70.3Â  39.2Â  38.2Â  77.9Â  40.7Â  38.9Â  23.3Â  40.5
Â Â  39.4Â  82.5Â  41.4Â  43.0Â Â  4.7Â  43.3Â  43.7Â Â  7.6Â  43.1
Â Â  46.4Â  84.1Â  41.5Â  46.7Â  10.6Â  42.6Â  49.9Â  22.1Â  40.7
Â Â  51.0Â  88.8Â  42.0Â  52.8Â  68.9Â  39.3Â  52.9Â  32.7Â  39.2
Â Â  55.5Â  92.9Â  42.2Â  56.0Â Â  1.6Â  42.7Â  60.6Â  75.2Â  40.1
Â Â  62.1Â  26.6Â  40.1Â  63.0Â  12.7Â  41.8Â  69.0Â  75.6Â  40.1
Â Â  70.5Â  83.7Â  40.9Â  70.9Â  11.0Â  41.7Â  71.5Â  29.5Â  39.8
Â Â  78.1Â  45.5Â  38.7Â  78.2Â Â  9.1Â  41.7Â  78.4Â  20.0Â  40.8
Â Â  80.5Â  55.9Â  38.7Â  81.1Â  51.0Â  38.6Â  83.8Â Â  7.9Â  41.6
Â Â  84.5Â  11.0Â  41.5Â  85.2Â  67.3Â  39.4Â  85.5Â  73.0Â  39.8
Â Â  86.7Â  70.4Â  39.6Â  87.2Â  55.7Â  38.8Â  88.1Â Â  0.0Â  41.6
Â Â  88.4Â  12.1Â  41.3Â  88.4Â  99.6Â  41.2Â  88.8Â  82.9Â  40.5
Â Â  88.9Â Â  6.2Â  41.5Â  90.6Â Â  7.0Â  41.5Â  90.7Â  49.6Â  38.9
Â Â  91.5Â  55.4Â  39.0Â  92.9Â  46.8Â  39.1Â  93.4Â  70.9Â  39.7
Â Â  55.8Â  50.5Â  38.1Â  96.2Â  84.3Â  40.3Â  98.2Â  58.2Â  39.5
;Â
ods graphics on;
proc sim2d data=chocolates outsim=sim plot=(observ sim);
Â Â  coordinates xc=munch yc=kitkat;
Â Â  simulate var=gems numreal=5000 seed=79931
Â Â Â Â Â  scale=7.4599 range=30.1111 nugget=1e-8 form=gauss;
Â Â  mean 40.1173;
Â Â  grid x=0 to 100 by 2.5 y=0 to 100 by 2.5;
run;```

Spatial Analysis in SAS/STAT –Â PROC SIM2D

SAS PROC SIM2D

Spatial Analysis in SAS/STAT –Â PROC SIM2D

#### c. PROC SPP

The SPP procedure in SAS/STAT describes the occurrence of observations by using spatial point pattern analysis. The observations are discrete and random, so through analysis, it characterizes the spatial process. Its unique abilities include fitting an inhomogeneous Poisson process, produce non-parametric estimates, compute correlation functions and many more. Apart from this, it also performs marked point pattern analysis.

A Syntax of PROC SPP-

```PROC SPP DATASET<options>;
PROCESS nameÂ =Â (variables </pattern-options>)</process-options <distance-function-options>>;
TRENDÂ nameÂ =Â FIELD(field-definitionÂ );```

TheÂ PROC SPP and PROCESS statement is required.

PROC SPP Example-

```ods graphics on;
proc spp data=sashelp.IRIS plots=all;
Â Â  process SPECIES = (SEPALLENGTH, SEPALWIDTH / EVENT=SPECIES);
Â Â  trend PETALLENGTH = field(SEPALLENGTH,SEPALWIDTH, PETALLENGTH );
Â Â  trend PETALWIDTH = field(SEPALLENGTH,SEPALWIDTH, PETALWIDTH);
run;```

The variables PETALLENGTH and PETALWIDTH are both continuous functions because any arbitrary point that is chosen in the study area has a value for both these variables.

In SAS/STAT spatial analysis, such CONTINUOUS variables are termed field variables and are associated with a spatial trend. They can be included in the SPP procedure by using the TREND statement.Â In the SPP procedure, you are required to identify the point pattern event identifier separately. This is done by using theÂ EVENT= option in theÂ PROCESS statement to specify that the variable SPECIES identifies the event.

SAS Spatial Analysis –Â PROC SPP

SAS Spatial Analysis –Â PROC SPP

SAS Spatial Analysis –Â PROC SPP

SAS Spatial Analysis –Â PROC SPP

SAS/STAT Spatial Analysis

#### d. PROC VARIOGRAM

The VARIOGRAM in SAS/STAT is usedÂ to describe the spatial covariance structure in spatial point referenced data by computing variogram diagnostics. SASÂ VARIOGRAM procedure has the ability to fit theoretical models so that they can be used for subsequent analysis and can also handle semivariogram and anisotropic models. It makes use of eight semivariogram models such as cubic, Gaussian, exponential, spheric and so on.
A Syntax PROC VARIOGRAM-

```PROC VARIOGRAM DATASET<options>;
COMPUTEÂ computation-options;Â
COORDINATES coordinate-variables;```

TheÂ PROC VARIOGRAM, COMPUTE, and COORDINATE statements are required.
PROC VARIOGRAM Example-

```ods graphics on;Â
proc variogram data=sashelp.IRIS plots=all;
Â Â  compute novariogram nhc=20;
Â Â  coordinates xcoord=sepallength ycoord=sepalwidth;
Â Â  var petalwidth;Â
run;```

SAS/STAT Spatial Analysis –Â PROC VARIOGRAM

SAS/STAT Spatial Analysis –Â PROC VARIOGRAM

SAS/STAT Spatial Analysis –Â PROC VARIOGRAM

So, this was allÂ about SAS/STAT Spatial Analysis Tutorial. Hope you like our explanation.

### Conclusion

Hence, this was all about SAS/STAT Spatial Analysis and procedures offered by spatial analysis in SAS/STAT:Â PROC KRIGE2D, PROC SIM2D, PROC SPP, and PROC VARIOGRAM with Examples & Syntax. For any queries, post your doubts in the comments section below.

Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google