CSPATIALREG Procedure
Spatial ID Matching
Depending on the type of model that you use in PROC CSPATIALREG, you might need to specify two data tables: one in the DATA= option and the other in the WMAT= option. In such cases, you must use a SPATIALID statement to specify a spatial ID variable in order to match observations in these two data tables.
As an example, assume that the data table that you specify in the DATA= option looks like the following:
data mylib.Example;
input SID $ x1 x2 y;
datalines;
L1 0.3 0.5 0.9
L3 -0.7 0.8 -0.4
L2 0.4 -1.2 0.6
L8 -1.7 1.2 -0.5
L4 1.4 0.9 0.3
L5 2.3 1.5 1.9
L7 -0.9 -0.8 -1.3
L6 1.4 -1.6 -2.0
;
run;
Suppose that the spatial contiguity matrix that you specify in the WMAT= option looks like the following:
data mylib.Cmat;
input SID $ L1 L8 L3 L4 L7 L6 L5 L2;
datalines;
L1 0 1 0 1 0 1 0 1
L2 1 0 0 0 1 0 0 0
L6 1 0 1 0 0 0 0 0
L4 1 0 0 0 1 0 0 0
L3 0 0 0 0 1 1 0 0
L7 0 0 1 1 0 0 0 1
L5 0 1 0 0 0 0 0 0
L8 1 0 0 0 0 0 1 0
;
run;
As you can see, rows in the two data tables mylib.Example and mylib.Cmat do not share identically sorted SID values. The second row in the Example data table contains the observation for a spatial unit L3, and its neighbor information is given in the fifth row of the mylib.Cmat data table. Moreover, the rows and columns of the spatial weights data table mylib.Cmat are not in the same order. The following SAS statements fit a SAR model to these data:
proc cspatialreg data=mylib.Example Wmat=mylib.Cmat;
model y=x1 x2/type=SAR;
spatialid SID;
run;
The SPATIALID statement enables you to match rows and columns of the mylib.Cmat data table in addition to rows of the mylib.Example and mylib.Cmat data tables.