Programming the statistical procedures from SAS

Fitting Spatial covariance model - Proc Mixed

Occasional Contributor
Posts: 11

Fitting Spatial covariance model - Proc Mixed

Dear All,

I am trying to fit various spatial covariance model such as spherical, exponential, gaussian, power, linear, linear log and other anisotropic structure using proc mixed. The spatial data has west longitude, latitude, and yield. I converted the spatial coordinates into easting and northing for efficient statistical analysis. Each time I run my SAS script for the entire data set which 12009 observations, I got insufficient memory despite running the script on system with 24 GB of RAM. I suspect the inability of REML algorithm to fit the 12009 x 12009 variance-covariance structure of R matrix of the residual term. Please see my script

  %spatialcov(var= cov=)

      proc mixed

         model &var=/ddfm=residual;

         repeated/subject=intercept type=sp(&cov)(easting northing);

         parms (25) (20);



    %mend spatialcov;

%spatialcov(var=yield cov=sph)

%spatialcov(var=yield cov=exp)

%spatialcov(var=yield cov=gau)

%spatialcov(var=yield cov=pow)

%spatialcov(var=yield cov=lin)

%spatialcov(var=yield cov=linl)

I have to substract a constant 321000 and 5708000 from easting and northing respectively when I discovered that the values are extremely high to facilitate the computation but all effort in vain. Please could any one advise me on better approach? Does it mean PROC MIXED can not fit spatial model with a very large dataset? Could anyone suggest alternative approach or how to modify my SAS code? Look forward to reading from you.

Regular Contributor
Posts: 152

Re: Fitting Spatial covariance model - Proc Mixed

Can you take multiple random samples of your data, run PROC MIXED on each of these samples, and then summarize the results across the samples?  If your sample were one-half the size of your original data set, the corresponding matrices would be only one-fourth the size as those from your original data set.

Or can you group observations near to one another and summarize/average their yields to reduce your sample size?

Valued Guide
Valued Guide
Posts: 684

Re: Fitting Spatial covariance model - Proc Mixed

You are probably running SAS 9.3. There is a 2 GB software memory limit in MIXED, not matter how much memory you have on your machine. Starting with SAS/STAT 12.1, this restriction has been eliminated.

Occasional Contributor
Posts: 11

Re: Fitting Spatial covariance model - Proc Mixed

Dear lvm,

I appreciate your informative response to my request. I would like to ask if SAS/STAT 12.1 is available for use now. I  have to think of alternative now that the usage of PROC MIXED is not feasible for my analysis. Could you please suggest any other approach? It is better I work with the entire data rather than subset.

My contact email is

Let us keep in touch please.

Valued Guide
Valued Guide
Posts: 684

Re: Fitting Spatial covariance model - Proc Mixed

12.1 has been available for about a year. But, your installation may not have it yet -- it depends when your installation gets the updates. Note, SAS/STAT 12.1 runs with SAS/Base 9.There is a cost for the increased memory: programs may run an extremely long time to reach convergence.

I would suggest you consider sampling of your dataset.

Respected Advisor
Posts: 2,655

Re: Fitting Spatial covariance model - Proc Mixed

The OP may also want to look at PROC KRIGE2D.  I think all (or almost all) of the spatial forms in the macro are available in that procedure.  I have to admit that I have never used it, but looking through the documentation examples, it seems like a possible alternative.

Steve Denham

Ask a Question
Discussion stats
  • 5 replies
  • 4 in conversation