A SAS program that
- Reads environmental data,
- Runs a regression, and
- Uses contour to make a map of the residuals
/*
INTERACT.SAS ANALYSIS THE INTERACTION VARIABLES FOR SANSAC
USES LEVEL-3 DATA FROM ERDAS -> PYRAMID FILES
LEE DE COLA
94/01/04
*/
%myopts(outmode = s) ;
*options ls = 64 ;
options nocenter ;
%include '~/human/sas/format.sas' ;
%macro makefile(infile, outfile) ;
data &outfile (keep = x y logelev -- category ) ;
set &infile ;
length default = 3 ;
logelev = log(elev + 1) ;
%do i = 1 %to 8 ;
if aspect = &i then
asp&i = 1 ;
else
asp&i = 0 ;
%end ;
if slope > 0 and slope < 5 then gentle = 1 ; else gentle = 0 ;
if slope > 4 then steep = 1 ; else steep = 0 ;
temp2 = (anntemp - 65)**2 ;
logprec = log(totprec) ;
logpop = log(popsurf + 1) ;
ndvi = meanndvi ;
category = landuse ;
if category = 5 then ndvi = 0 ;
format category category. ;
%mend makefile ;
%macro analyze (infile) ;
data temp ;
set &infile ;
pop2 = logpop**2 ;
proc reg noprint data = temp ;
model ndvi = x y logelev -- logprec / partial ;
output out = resid r = resid ;
proc sort data = resid out = temp ;
by y x ;
data temp ;
set temp ;
file '~/transfer/resid.dat' ;
format ndvi 8.0 resid 8.2 ;
put ndvi resid ;
run ;
%mend analyze ;
%macro map(infile, var) ;
data temp ;
set &infile ;
category = landuse ;
if category = 5 then ndvi = 0 ;
format category category. ;
proc gcontour data = temp ;
plot y * x = &var /
join
haxis = axis1
vaxis = axis2
pattern
legend = legend1
levels = 1 2 3 4 5
;
run ;
%mend map ;
title "ANALYSIS OF SAN-SAC INTERACTIONS" ;
*%makefile(sasdata.sansac, sasdata.interact) ;
%analyze(sasdata.interact) ;
*%map(sasdata.sansac, category) ;