First off, you can do just about anything with SAS. Basically, I took your code and wrapped the parts that run the proc dbf and proc variogram in a macro, since that code runs repetitively for each dbf in the folder. I added a data step after the ods output to reformat your ods output then appended it to a results data set that captures the stats for each run. Also, instead of using the list with the file names, I opted to read the file names directly from the folder by piping the dir command. Here's the code. %let mydir = c:\data\test; libname mylib "&mydir"; DATA mylib.u107all; length CODE $ 56.; infile "&mydir\u107all.csv" dsd dlm=',' firstobs=2; input CODE $ thevariable; RUN; %macro analyze_dbf( fnm ); %let last4 = %substr( %scan( &fnm, 1, . ), 5, 4 ); filename m "&mydir\&fnm"; PROC DBF db5=m out=mylib.m&last4; run; PROC SQL; create table mylib.ma&last4 as select A.CODE, A.thevariable, B.CODE, B.POINT_X, B.POINT_Y from mylib.u107all A, mylib.m&last4 B where A.CODE = B.CODE; QUIT; ods output "Autocorrelation Statistics" = mylib.moran&last4; PROC VARIOGRAM data=mylib.ma&last4; compute novar autoc (weights=distance); coordinates xc=POINT_X yc=POINT_Y; var thevariable; run; quit; ods output close; data stats; ma = &last4; do until ( done ); set mylib.moran&last4 end=done; if coefficient =: 'Moran' then do; morano = observedvalue; morane = expectedvalue; mz = z; mp = pvalue; end; else if coefficient =: 'Geary' then do; gearyo = observedvalue; gz = z; gp = pvalue; end; end; output; keep ma morano--gp; run; proc append base=mylib.results data=stats; run; %mend; filename x pipe "dir /b &mydir\*.dbf"; data _null_; infile x; input fnm :$15.; call execute ( cats( '%analyze_dbf(', strip(fnm), ');' )); run;
... View more