I'm trying to run a demo below to create a matrix weight data to feed proc spatialreg model, in Paper 2481-2018
Creating a Spatial Weights Matrix for the SPATIALREG Procedure, Alan Ricardo da Silva.
However, I get below error:
"237 %WMATRIX(map=columbus, id=code, lat=y, long=x, type=contiguity,
238 out=neighbor_columbus); run;
ERROR: File WORK.COLUMBUS.DATA does not exist."
Do you know how to get hold of map data? My project is concerned with New York not Columbus
I suspect there must be SAS map library
that I have to specify to the macro? Could you please show me how to do it for New York?
Thanks for help.
%macro Wmatrix(map=,id=,lat=,long=,type=contiguity,centroid_lat=,
centroid_long=, distance=,neighbors=,out=neighbor);
%if %upcase(&type)=CONTIGUITY %then %do;
%if &neighbors = %then %do;
/********Defining the Neighborhood for contiguity ***********/
proc sort data=&map out=&map.2 nodupkey; by &long &lat &id;run;
data _hashmap_ (keep=&long &lat z &id);
retain z;
set &map.2(where=(&long NE . and &lat NE .));
by &long ⪫
if first.&long or first.&lat then z=1;
z=z+1;
run;
proc means data=_hashmap_ noprint;
output out=maxz max(z)=mz; run;
/*put the maximum value of z into macro variable maxnb*/
data _null_;
set maxz;
call symputx("maxnb",mz);
run;
%put &maxnb;
proc sort data=&map.2; by &id;run;
data nonb (keep=myid);
/*length &long &lat z 8; format &id 16.;*/
if _n_=1 then do;
/*this hash object holds a second copy of the entire map for comparison*/
declare hash fc(dataset: "_hashmap_");
fc.definekey("&long","&lat","z");
fc.definedata("&long","&lat","z","&id");
fc.definedone();
call missing (&long,&lat,z,&id);
/*this hash object will hold the rook neighbors for each area: they have two
points in common*/
declare hash rook();
rook.definekey("&id","myid");
rook.definedata("&id","myid");
rook.definedone();
end;
/*this hash object holds the bishop neighbors for each area: they have a
point
in common*/
declare hash bishop();
bishop.definekey("&id","myid");
bishop.definedata("&id","myid");
bishop.definedone();
foundnb="N";
do until (last.myid);
set &map.2 (keep=&id &long &lat rename=(&id=myid &long=myx &lat=myy)
where=(myx NE .
and myy NE .)) end=eof;
by myid;
do n=1 to &maxnb.; /*this is max number of points in common =max z*/
rc=fc.find(key:myx, key:myy, key:n);
if rc=0 and myid NE &id then do;
nbrc=rook.check(key:&id, key:myid);
if nbrc=0 then do;
rc2=rook.add(key:&id, key:myid, data:&id, data:myid);
foundnb="Y";
end;
else rc1=rook.add(key:&id, key:myid, data:&id, data:myid);
end;
end;*do &maxnb.;
end;*end DOW loop;
if foundnb="N" then output nonb;
if eof then rook.output(dataset:"&out");
run;
proc sort data=&out;by &id myid;run;
proc sort data=&out(keep=&id) nodupkey out=_tab_;by &id;run;
data _tab_;set _tab_;idi=_n_;run;
proc sort data=&out;by &id;run;
data _tab2_;merge &out _tab_;by &id;run;
proc sort data=_tab2_;by myid;run;
data _tab2_;merge _tab2_ _tab_(rename=(idi=idj &id=myid));by myid;run;
proc sort data=_tab2_;by &id;run;
proc sql;drop table _tab_,_hashmap_,Nonb,Maxz,&map.2;quit;
data Wmatrix_compact;set &out(rename=myid=c&id);
value=1;
run;
%end;
%else %do;
%if ¢roid_lat= or ¢roid_long= %then %do;
%annomac;
proc sort data=&map(keep=&id &lat &long rename=(&long=y &lat=x)) out=_↦by
&id;run;
%centroid(_&map,&out,&id);
proc sql;drop table _↦quit;
%end;
%else %do;
data &out;set &map(keep=&id ¢roid_lat ¢roid_long
rename=(¢roid_long=y ¢roid_lat=x));run;
%end;
proc iml;
use &out;
read all var{x y} into COORD;
n=nrow(coord[,1]);
*print n;
d=j(1,3,0);
nome={"idi" "idj" "d"};
create _dist_ from d[colname=nome];
do i=1 to n;
do j=1 to n;
d[1]=i;
d[2]=j;
d[3]=sqrt((COORD[i,1]-COORD[j,1])**2+(COORD[i,2]-COORD[j,2])**2);
append from d;
end;
end;
close _dist_;
data &out;set &map(keep=&id ¢roid_lat ¢roid_long
rename=(¢roid_long=y ¢roid_lat=x));run;
%end;
proc iml;
use &out;
read all var{x y} into COORD;
n=nrow(coord[,1]);
*print n;
d=j(1,3,0);
nome={"idi" "idj" "d"};
create _dist_ from d[colname=nome];
do i=1 to n;
do j=i+1 to n;
d[1]=i;
d[2]=j;
d[3]=sqrt((COORD[i,1]-COORD[j,1])**2+(COORD[i,2]-COORD[j,2])**2);
append from d;
end;
end;
close _dist_;
quit;
data &out;set _dist_;run;
proc sql;drop table _dist_;quit;
data Wmatrix_compact;
set &out(rename=(idi=&id idj=c&id)) &out(rename=(idi=c&id idj=&id));
%if &distance= %then %do;
value=1/d;
%end;
%else %do;
if d<=&distance then value=1;
if value=. then delete;
%end;
keep &id c&id value;
run;
proc sort data=Wmatrix_compact;by &id c&id;run;
/********creating W Matrix ***********/
proc iml;
use &out var{idi idj d};
read all;
n=max(idj);
w=j(n,n,0);
do h=1 to nrow(idi);
%if &distance= %then %do;
w[idi[h],idj[h]]=1/d[h];
w[idj[h],idi[h]]=1/d[h];
%end;
%else %do;
if d[h]<=&distance then do;
w[idi[h],idj[h]]=1;
w[idj[h],idi[h]]=1;
end;
%end;
end;
wpdr=j(n,n,0);
soma=j(n,1,0);
do i=1 to n;
do j=1 to n;
soma[i]=soma[i]+w[i,j];
end;
end;
do i=1 to n;
do j=1 to n;
if soma[i]=0 then wpdr[i,j]=0;
else wpdr[i,j]=w[i,j]/soma[i];
end;
end;
create Wmatrix from w;
append from w;
create Wmatrix_sdr from wpdr;
append from wpdr;
quit;
%end;
%mend Wmatrix;
/*crime data*/
data crimeoh;
input crime income hvalue lat lon;
datalines;
18.802 21.232 44.567 35.62 42.38
32.388 4.477 33.200 36.50 40.52
38.426 11.337 37.125 36.71 38.71
0.178 8.438 75.000 33.36 38.41
15.726 19.531 80.467 38.80 44.07
30.627 15.956 26.350 39.82 41.18
50.732 11.252 23.225 40.01 38.00
26.067 16.029 28.750 43.75 39.28
48.585 9.873 18.000 39.61 34.91
34.001 13.598 96.400 47.61 36.42
36.869 9.798 41.750 48.58 34.46
20.049 21.155 47.733 49.61 32.65
19.146 18.942 40.300 50.11 29.91
18.905 22.207 42.100 51.24 27.80
27.823 18.950 42.500 50.89 25.24
16.241 29.833 61.950 48.44 27.93
0.224 31.070 81.267 46.73 31.91
30.516 17.586 52.600 43.44 35.92
33.705 11.709 30.450 43.37 33.46
40.970 8.085 20.300 41.13 33.14
52.794 10.822 34.100 43.95 31.61
41.968 9.918 23.600 44.10 30.40
39.175 12.814 27.000 43.70 29.18
53.711 11.107 22.700 41.04 28.78
25.962 16.961 33.500 43.23 27.31
22.541 18.796 35.800 42.67 24.96
26.645 11.813 26.800 41.21 25.90
29.028 14.135 27.733 39.32 25.85
36.664 13.380 25.700 41.09 27.49
42.445 17.017 43.300 38.32 28.82
56.920 7.856 22.850 41.31 30.90
61.299 8.461 17.900 39.36 32.88
60.750 8.681 32.500 39.72 30.64
68.892 13.906 22.500 38.29 30.35
38.298 14.236 53.200 36.60 32.09
54.839 7.625 18.800 37.60 34.08
56.706 10.048 19.900 37.13 36.12
62.275 7.467 19.700 37.85 36.30
46.716 9.549 41.700 35.95 36.40
57.066 9.963 42.900 35.72 35.60
54.522 11.618 30.600 35.76 34.66
43.962 13.185 60.000 36.15 33.92
40.074 10.655 19.975 34.08 30.42
23.974 14.948 28.450 30.32 28.26
17.677 16.940 31.800 27.94 29.85
14.306 18.739 36.300 27.27 28.21
19.101 18.477 39.600 24.25 26.69
16.531 18.324 76.100 25.47 25.71
16.492 25.873 44.333 29.02 26.58
;
%WMATRIX(map=columbus, id=code, lat=y, long=x, type=contiguity,
out=neighbor_columbus); run;
Hi @Reeza, would you please take a look at code below ? why I get error even though I have a dataset with centroids now.
Error I get:
ERROR: Variable X not found.
ERROR: Variable Y not found.
ERROR: Variable CODE not found.
From below code:
proc import datafile="\ ...\centroid\2017_ny_centroid.txt"
out=map1
dbms=tab replace;
getnames=yes;
run;
data columbus;
set map1(rename=(GEOID=id INTPTLAT=centroid_lat INTPTLONG=centroid_long));
run;
%macro Wmatrix(map=,id=,lat=,long=,type=contiguity,centroid_lat=,
centroid_long=, distance=,neighbors=,out=neighbor);
...hashtag macro here...
%WMATRIX(map=columbus, id=code, lat=y, long=x, type=contiguity,
out=neighbor_columbus); run;
Full log please.
I see your centroids, but not xy. If you upload the csv I’ll try and run it a bit later.
If you copied and pasted the macro from the PDF make sure there’s no weird characters in there as well.
Thanks a lot!
Below is a full log. To avoid strange characters from pdf I copied codes one page at a time to avoid characters from the parts where pages end and start in pdf document. Attached is newyork csv. I think, x and y are created from centroid_lat and centroid_long in the map dataset in the macro. See below.
data &out;set &map(keep=&id ¢roid_lat ¢roid_long
rename=(¢roid_long=y ¢roid_lat=x));run;
For your convenience, proc import for new york csv is following.
proc import datafile="...\newyork.csv"
out=newyork
dbms=csv replace;
getnames=yes;
run;
1270
1271 %macro Wmatrix(map=,id=,lat=,long=,type=contiguity,centroid_lat=,
1272 centroid_long=, distance=,neighbors=,out=neighbor);
1273
1274 %if %upcase(&type)=CONTIGUITY %then %do;
1275 %if &neighbors = %then %do;
1276 /********Defining the Neighborhood for contiguity ***********/
1277 proc sort data=&map out=&map.2 nodupkey; by &long &lat &id;run;
1278 data _hashmap_ (keep=&long &lat z &id);
1279 retain z;
1280 set &map.2(where=(&long NE . and &lat NE .));
1281 by &long ⪫
1282 if first.&long or first.&lat then z=1;
1283 z=z+1;
1284 run;
1285 proc means data=_hashmap_ noprint;
1286 output out=maxz max(z)=mz; run;
1287 /*put the maximum value of z into macro variable maxnb*/
1288 data _null_;
1289 set maxz;
1290 call symputx("maxnb",mz);
1291 run;
1292 %put &maxnb;
1293 proc sort data=&map.2; by &id;run;
1294 data nonb (keep=myid);
1295 /*length &long &lat z 8; format &id 16.;*/
1296 if _n_=1 then do;
1297 /*this hash object holds a second copy of the entire map for comparison*/
1298 declare hash fc(dataset: "_hashmap_");
1299 fc.definekey("&long","&lat","z");
1300 fc.definedata("&long","&lat","z","&id");
1301 fc.definedone();
1302 call missing (&long,&lat,z,&id);
1303 /*this hash object will hold the rook neighbors for each area: they have two
1304 points in common*/
1305 declare hash rook();
1306 rook.definekey("&id","myid");
1307 rook.definedata("&id","myid");
1308 rook.definedone();
1309 end;
1310 /*this hash object holds the bishop neighbors for each area: they have a
1311 point
1312 in common*/
1313 declare hash bishop();
1314 bishop.definekey("&id","myid");
1315 bishop.definedata("&id","myid");
1316 bishop.definedone();
1317 foundnb="N";
1318 do until (last.myid);
1319 set &map.2 (keep=&id &long &lat rename=(&id=myid &long=myx &lat=myy)
1320 where=(myx NE .
1321 and myy NE .)) end=eof;
1322 by myid;
1323 do n=1 to &maxnb.; /*this is max number of points in common =max z*/
1324 rc=fc.find(key:myx, key:myy, key:n);
1325 if rc=0 and myid NE &id then do;
1326 nbrc=rook.check(key:&id, key:myid);
1327 if nbrc=0 then do;
1328 rc2=rook.add(key:&id, key:myid, data:&id, data:myid);
1329 foundnb="Y";
1330 end;
1331 else rc1=rook.add(key:&id, key:myid, data:&id, data:myid);
1332 end;
1333 end;*do &maxnb.;
1334 end;*end DOW loop;
1335 if foundnb="N" then output nonb;
1336 if eof then rook.output(dataset:"&out");
1337 run;
1338 proc sort data=&out;by &id myid;run;
1339 proc sort data=&out(keep=&id) nodupkey out=_tab_;by &id;run;
1340 data _tab_;set _tab_;idi=_n_;run;
1341 proc sort data=&out;by &id;run;
1342 data _tab2_;merge &out _tab_;by &id;run;
1343 proc sort data=_tab2_;by myid;run;
1344 data _tab2_;merge _tab2_ _tab_(rename=(idi=idj &id=myid));by myid;run;
1345 proc sort data=_tab2_;by &id;run;
1346 proc sql;drop table _tab_,_hashmap_,Nonb,Maxz,&map.2;quit;
1347 data Wmatrix_compact;set &out(rename=myid=c&id);
1348 value=1;
1349 run;
1350 %end;
1351 %else %do;
1352 %if ¢roid_lat= or ¢roid_long= %then %do;
1353 %annomac;
1354 proc sort data=&map(keep=&id &lat &long rename=(&long=y &lat=x)) out=_↦by
1355 &id;run;
1356 %centroid(_&map,&out,&id);
1357 proc sql;drop table _↦quit;
1358 %end;
1359 %else %do;
1360 data &out;set &map(keep=&id ¢roid_lat ¢roid_long
1361 rename=(¢roid_long=y ¢roid_lat=x));run;
1362 %end;
1363 proc iml;
1364 use &out;
1365 read all var{x y} into COORD;
1366 n=nrow(coord[,1]);
1367 *print n;
1368 d=j(1,3,0);
1369 nome={"idi" "idj" "d"};
1370 create _dist_ from d[colname=nome];
1371 do i=1 to n;
1372 do j=1 to n;
1373 d[1]=i;
1374 d[2]=j;
1375 d[3]=sqrt((COORD[i,1]-COORD[j,1])**2+(COORD[i,2]-COORD[j,2])**2);
1376 append from d;
1377 end;
1378 end;
1379 close _dist_;
1380 data &out;set &map(keep=&id ¢roid_lat ¢roid_long
1381 rename=(¢roid_long=y ¢roid_lat=x));run;
1382 %end;
1383 proc iml;
1384 use &out;
1385 read all var{x y} into COORD;
1386 n=nrow(coord[,1]);
1387 *print n;
1388 d=j(1,3,0);
1389 nome={"idi" "idj" "d"};
1390 create _dist_ from d[colname=nome];
1391 do i=1 to n;
1392 do j=i+1 to n;
1393 d[1]=i;
1394 d[2]=j;
1395 d[3]=sqrt((COORD[i,1]-COORD[j,1])**2+(COORD[i,2]-COORD[j,2])**2);
1396 append from d;
1397 end;
1398 end;
1399 close _dist_;
1400 quit;
1401 data &out;set _dist_;run;
1402 proc sql;drop table _dist_;quit;
1403 data Wmatrix_compact;
1404 set &out(rename=(idi=&id idj=c&id)) &out(rename=(idi=c&id idj=&id));
1405 %if &distance= %then %do;
1406 value=1/d;
1407 %end;
1408 %else %do;
1409 if d<=&distance then value=1;
1410 if value=. then delete;
1411 %end;
1412 keep &id c&id value;
1413 run;
1414 proc sort data=Wmatrix_compact;by &id c&id;run;
1415 /********creating W Matrix ***********/
1416 proc iml;
1417 use &out var{idi idj d};
1418 read all;
1419 n=max(idj);
1420 w=j(n,n,0);
1421 do h=1 to nrow(idi);
1422 %if &distance= %then %do;
1423 w[idi[h],idj[h]]=1/d[h];
1424 w[idj[h],idi[h]]=1/d[h];
1425 %end;
1426 %else %do;
1427 if d[h]<=&distance then do;
1428 w[idi[h],idj[h]]=1;
1429 w[idj[h],idi[h]]=1;
1430 end;
1431 %end;
1432 end;
1433 wpdr=j(n,n,0);
1434 soma=j(n,1,0);
1435 do i=1 to n;
1436 do j=1 to n;
1437 soma[i]=soma[i]+w[i,j];
1438 end;
1439 end;
1440 do i=1 to n;
1441 do j=1 to n;
1442 if soma[i]=0 then wpdr[i,j]=0;
1443 else wpdr[i,j]=w[i,j]/soma[i];
1444 end;
1445 end;
1446 create Wmatrix from w;
1447 append from w;
1448 create Wmatrix_sdr from wpdr;
1449 append from wpdr;
1450 quit;
1451 %end;
1452 %mend Wmatrix;
1453 %WMATRIX(map=newyork, id=code, lat=y, long=x, type=contiguity,
1454 out=neighbor_columbus); run;
ERROR: Variable X not found.
ERROR: Variable Y not found.
ERROR: Variable CODE not found.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.NEWYORK2 may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.NEWYORK2 was not replaced because this step was stopped.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
ERROR: Variable x is not on file WORK.NEWYORK2.
WARNING: The variable x in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable y in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable code in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._HASHMAP_ may be incomplete. When this step was stopped there were 0
observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: No observations in data set WORK._HASHMAP_.
NOTE: The data set WORK.MAXZ has 0 observations and 3 variables.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: There were 0 observations read from the data set WORK.MAXZ.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
WARNING: Apparent symbolic reference MAXNB not resolved.
&maxnb
ERROR: Variable CODE not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Line generated by the invoked macro "WMATRIX".
6 (keep=&id &long &lat rename=(&id=myid &long=myx &lat=myy) where=(myx NE . and myy NE .))
6 ! end=eof; by myid; do n=1 to &maxnb.; rc=fc.find(key:myx, key:myy, key:n); if rc=0 and myid
-
386
6 ! NE &id then do; nbrc=rook.check(key:&id, key:myid); if nbrc=0 then do;
ERROR 386-185: Expecting an arithmetic expression.
NOTE: Line generated by the invoked macro "WMATRIX".
6 (keep=&id &long &lat rename=(&id=myid &long=myx &lat=myy) where=(myx NE . and myy NE .))
6 ! end=eof; by myid; do n=1 to &maxnb.; rc=fc.find(key:myx, key:myy, key:n); if rc=0 and myid
-
200
6 ! NE &id then do; nbrc=rook.check(key:&id, key:myid); if nbrc=0 then do;
ERROR 200-322: The symbol is not recognized and will be ignored.
ERROR: Variable code is not on file WORK.NEWYORK2.
ERROR: Variable x is not on file WORK.NEWYORK2.
ERROR: Variable y is not on file WORK.NEWYORK2.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.NEWYORK2.
WARNING: Apparent symbolic reference MAXNB not resolved.
ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
ERROR: Variable CODE not found.
ERROR: Variable MYID not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
ERROR: The variable code in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._TAB_ may be incomplete. When this step was stopped there were 0
observations and 0 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK._TAB_.
NOTE: The data set WORK._TAB_ has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
ERROR: Variable CODE not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: BY variable code is not on input data set WORK.NEIGHBOR_COLUMBUS.
ERROR: BY variable code is not on input data set WORK._TAB_.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._TAB2_ may be incomplete. When this step was stopped there were 0
observations and 3 variables.
WARNING: Data set WORK._TAB2_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable MYID not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable code is not on file WORK._TAB_.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK._TAB_.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._TAB2_ may be incomplete. When this step was stopped there were 0
observations and 1 variables.
WARNING: Data set WORK._TAB2_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: Variable CODE not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Table WORK._TAB_ has been dropped.
NOTE: Table WORK._HASHMAP_ has been dropped.
WARNING: File WORK.NONB.DATA does not exist.
WARNING: Table WORK.NONB has not been dropped.
NOTE: Table WORK.MAXZ has been dropped.
NOTE: Table WORK.NEWYORK2 has been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable myid is not on file WORK.NEIGHBOR_COLUMBUS.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.NEIGHBOR_COLUMBUS.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WMATRIX_COMPACT may be incomplete. When this step was stopped there
were 0 observations and 1 variables.
WARNING: Data set WORK.WMATRIX_COMPACT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
NOTE: IML Ready
WARNING: Data set WORK.NEIGHBOR_COLUMBUS is empty.
statement : USE at line 2094 column 12
WARNING: End of File reached.
statement : READ at line 2094 column 22
ERROR: (execution) Matrix has not been set to a value.
operation : [ at line 2094 column 64
operands : coord, , *LIT1002
COORD 0 row 0 col (type ?, size 0)
*LIT1002 1 row 1 col (numeric)
1
statement : ASSIGN at line 2094 column 52
ERROR: DO expression not given value.
statement : DO at line 2094 column 153
NOTE: The data set WORK._DIST_ has 0 observations and 3 variables.
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
real time 0.15 seconds
cpu time 0.01 seconds
NOTE: There were 0 observations read from the data set WORK._DIST_.
NOTE: The data set WORK.NEIGHBOR_COLUMBUS has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
NOTE: Table WORK._DIST_ has been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
NOTE: There were 0 observations read from the data set WORK.NEIGHBOR_COLUMBUS.
NOTE: There were 0 observations read from the data set WORK.NEIGHBOR_COLUMBUS.
NOTE: The data set WORK.WMATRIX_COMPACT has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
NOTE: Input data set is empty.
NOTE: The data set WORK.WMATRIX_COMPACT has 0 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: IML Ready
WARNING: Data set WORK.NEIGHBOR_COLUMBUS is empty.
statement : USE at line 2107 column 87
WARNING: End of File reached.
statement : READ at line 2107 column 112
ERROR: (execution) Matrix has not been set to a value.
operation : MAX at line 2107 column 127
operands : idj
idj 0 row 0 col (numeric)
statement : ASSIGN at line 2107 column 122
ERROR: (execution) Matrix has not been set to a value.
operation : J at line 2107 column 137
operands : n, n, *LIT1002
n 0 row 0 col (type ?, size 0)
n 0 row 0 col (type ?, size 0)
*LIT1002 1 row 1 col (numeric)
0
statement : ASSIGN at line 2107 column 134
ERROR: (execution) Matrix has not been set to a value.
operation : J at line 2117 column 13
operands : n, n, *LIT1006
n 0 row 0 col (type ?, size 0)
n 0 row 0 col (type ?, size 0)
*LIT1006 1 row 1 col (numeric)
0
statement : ASSIGN at line 2117 column 7
ERROR: (execution) Matrix has not been set to a value.
operation : J at line 2117 column 28
operands : n, *LIT1007, *LIT1008
n 0 row 0 col (type ?, size 0)
*LIT1007 1 row 1 col (numeric)
1
*LIT1008 1 row 1 col (numeric)
0
statement : ASSIGN at line 2117 column 22
ERROR: DO expression not given value.
statement : DO at line 2117 column 37
ERROR: DO expression not given value.
statement : DO at line 2117 column 97
ERROR: Matrix w has not been set to a value.
statement : CREATE at line 2117 column 195
ERROR: No data set is currently open for output.
statement : APPEND at line 2117 column 218
ERROR: Matrix wpdr has not been set to a value.
statement : CREATE at line 2117 column 233
ERROR: No data set is currently open for output.
statement : APPEND at line 2118 column 8
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
Were you able to get it solved?
I tried with both the sample data and got more errors and with your data and got more errors as well so I'm questioning if the macro is up to date. I would suggest contacting the authors at this point and ask if they can give you the demo code that works and then you can align your data to that.
The following does generate a weight data set, I have no idea if it's correct or not though and there are errors in the code.
proc import out=NY datafile='/folders/myfolders/newyork.csv'
dbms=csv replace;
guessingrows=max;
run;
%Wmatrix(map=NY,id=id,lat=centroid_lat,long=centroid_long,out=neighbor);
Your code outputs datasets: neighbor Wmatrix_compact _tab2_ but all empty. It's great that you were able at least to produce a dataset. Do you mind to share your resulting matrix data in csv? or any idea what I'm doing differently from you?
1913
1914 %macro Wmatrix(map=,id=,lat=,long=,type=contiguity,centroid_lat=,
1915 centroid_long=, distance=,neighbors=,out=neighbor);
1916
1917 %if %upcase(&type)=CONTIGUITY %then %do;
1918 %if &neighbors = %then %do;
1919 /********Defining the Neighborhood for contiguity ***********/
1920 proc sort data=&map out=&map.2 nodupkey; by &long &lat &id;run;
1921 data _hashmap_ (keep=&long &lat z &id);
1922 retain z;
1923 set &map.2(where=(&long NE . and &lat NE .));
1924 by &long ⪫
1925 if first.&long or first.&lat then z=1;
1926 z=z+1;
1927 run;
1928 proc means data=_hashmap_ noprint;
1929 output out=maxz max(z)=mz; run;
1930 /*put the maximum value of z into macro variable maxnb*/
1931 data _null_;
1932 set maxz;
1933 call symputx("maxnb",mz);
1934 run;
1935 %put &maxnb;
1936 proc sort data=&map.2; by &id;run;
1937 data nonb (keep=myid);
1938 /*length &long &lat z 8; format &id 16.;*/
1939 if _n_=1 then do;
1940 /*this hash object holds a second copy of the entire map for comparison*/
1941 declare hash fc(dataset: "_hashmap_");
1942 fc.definekey("&long","&lat","z");
1943 fc.definedata("&long","&lat","z","&id");
1944 fc.definedone();
1945 call missing (&long,&lat,z,&id);
1946 /*this hash object will hold the rook neighbors for each area: they have two
1947 points in common*/
1948 declare hash rook();
1949 rook.definekey("&id","myid");
1950 rook.definedata("&id","myid");
1951 rook.definedone();
1952 end;
1953 /*this hash object holds the bishop neighbors for each area: they have a
1954 point
1955 in common*/
1956 declare hash bishop();
1957 bishop.definekey("&id","myid");
1958 bishop.definedata("&id","myid");
1959 bishop.definedone();
1960 foundnb="N";
1961 do until (last.myid);
1962 set &map.2 (keep=&id &long &lat rename=(&id=myid &long=myx &lat=myy)
1963 where=(myx NE .
1964 and myy NE .)) end=eof;
1965 by myid;
1966 do n=1 to &maxnb.; /*this is max number of points in common =max z*/
1967 rc=fc.find(key:myx, key:myy, key:n);
1968 if rc=0 and myid NE &id then do;
1969 nbrc=rook.check(key:&id, key:myid);
1970 if nbrc=0 then do;
1971 rc2=rook.add(key:&id, key:myid, data:&id, data:myid);
1972 foundnb="Y";
1973 end;
1974 else rc1=rook.add(key:&id, key:myid, data:&id, data:myid);
1975 end;
1976 end;*do &maxnb.;
1977 end;*end DOW loop;
1978 if foundnb="N" then output nonb;
1979 if eof then rook.output(dataset:"&out");
1980 run;
1981 proc sort data=&out;by &id myid;run;
1982 proc sort data=&out(keep=&id) nodupkey out=_tab_;by &id;run;
1983 data _tab_;set _tab_;idi=_n_;run;
1984 proc sort data=&out;by &id;run;
1985 data _tab2_;merge &out _tab_;by &id;run;
1986 proc sort data=_tab2_;by myid;run;
1987 data _tab2_;merge _tab2_ _tab_(rename=(idi=idj &id=myid));by myid;run;
1988 proc sort data=_tab2_;by &id;run;
1989 proc sql;drop table _tab_,_hashmap_,Nonb,Maxz,&map.2;quit;
1990 data Wmatrix_compact;set &out(rename=myid=c&id);
1991 value=1;
1992 run;
1993 %end;
1994 %else %do;
1995 %if ¢roid_lat= or ¢roid_long= %then %do;
1996 %annomac;
1997 proc sort data=&map(keep=&id &lat &long rename=(&long=y &lat=x)) out=_↦by
1998 &id;run;
1999 %centroid(_&map,&out,&id);
2000 proc sql;drop table _↦quit;
2001 %end;
2002 %else %do;
2003 data &out;set &map(keep=&id ¢roid_lat ¢roid_long
2004 rename=(¢roid_long=y ¢roid_lat=x));run;
2005 %end;
2006 proc iml;
2007 use &out;
2008 read all var{x y} into COORD;
2009 n=nrow(coord[,1]);
2010 *print n;
2011 d=j(1,3,0);
2012 nome={"idi" "idj" "d"};
2013 create _dist_ from d[colname=nome];
2014 do i=1 to n;
2015 do j=1 to n;
2016 d[1]=i;
2017 d[2]=j;
2018 d[3]=sqrt((COORD[i,1]-COORD[j,1])**2+(COORD[i,2]-COORD[j,2])**2);
2019 append from d;
2020 end;
2021 end;
2022 close _dist_;
2023 data &out;set &map(keep=&id ¢roid_lat ¢roid_long
2024 rename=(¢roid_long=y ¢roid_lat=x));run;
2025 %end;
2026 proc iml;
2027 use &out;
2028 read all var{x y} into COORD;
2029 n=nrow(coord[,1]);
2030 *print n;
2031 d=j(1,3,0);
2032 nome={"idi" "idj" "d"};
2033 create _dist_ from d[colname=nome];
2034 do i=1 to n;
2035 do j=i+1 to n;
2036 d[1]=i;
2037 d[2]=j;
2038 d[3]=sqrt((COORD[i,1]-COORD[j,1])**2+(COORD[i,2]-COORD[j,2])**2);
2039 append from d;
2040 end;
2041 end;
2042 close _dist_;
2043 quit;
2044 data &out;set _dist_;run;
2045 proc sql;drop table _dist_;quit;
2046 data Wmatrix_compact;
2047 set &out(rename=(idi=&id idj=c&id)) &out(rename=(idi=c&id idj=&id));
2048 %if &distance= %then %do;
2049 value=1/d;
2050 %end;
2051 %else %do;
2052 if d<=&distance then value=1;
2053 if value=. then delete;
2054 %end;
2055 keep &id c&id value;
2056 run;
2057 proc sort data=Wmatrix_compact;by &id c&id;run;
2058 /********creating W Matrix ***********/
2059 proc iml;
2060 use &out var{idi idj d};
2061 read all;
2062 n=max(idj);
2063 w=j(n,n,0);
2064 do h=1 to nrow(idi);
2065 %if &distance= %then %do;
2066 w[idi[h],idj[h]]=1/d[h];
2067 w[idj[h],idi[h]]=1/d[h];
2068 %end;
2069 %else %do;
2070 if d[h]<=&distance then do;
2071 w[idi[h],idj[h]]=1;
2072 w[idj[h],idi[h]]=1;
2073 end;
2074 %end;
2075 end;
2076 wpdr=j(n,n,0);
2077 soma=j(n,1,0);
2078 do i=1 to n;
2079 do j=1 to n;
2080 soma[i]=soma[i]+w[i,j];
2081 end;
2082 end;
2083 do i=1 to n;
2084 do j=1 to n;
2085 if soma[i]=0 then wpdr[i,j]=0;
2086 else wpdr[i,j]=w[i,j]/soma[i];
2087 end;
2088 end;
2089 create Wmatrix from w;
2090 append from w;
2091 create Wmatrix_sdr from wpdr;
2092 append from wpdr;
2093 quit;
2094 %end;
2095 %mend Wmatrix;
2096 %Wmatrix(map=NY,id=id,lat=centroid_lat,long=centroid_long,out=neighbor); run;
NOTE: There were 1794 observations read from the data set WORK.NY.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.NY2 has 1794 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: There were 1794 observations read from the data set WORK.NY2.
WHERE (centroid_long not = .) and (centroid_lat not = .);
NOTE: The data set WORK._HASHMAP_ has 1794 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.10 seconds
cpu time 0.00 seconds
NOTE: There were 1794 observations read from the data set WORK._HASHMAP_.
NOTE: The data set WORK.MAXZ has 1 observations and 3 variables.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.04 seconds
cpu time 0.01 seconds
NOTE: There were 1 observations read from the data set WORK.MAXZ.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2
NOTE: There were 1794 observations read from the data set WORK.NY2.
NOTE: The data set WORK.NY2 has 1794 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: There were 1794 observations read from the data set WORK._HASHMAP_.
NOTE: The data set WORK.NEIGHBOR has 0 observations and 2 variables.
NOTE: There were 1794 observations read from the data set WORK.NY2.
WHERE (myx not = .) and (myy not = .);
NOTE: The data set WORK.NONB has 1794 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 1.09 seconds
cpu time 1.09 seconds
NOTE: Input data set is empty.
NOTE: The data set WORK.NEIGHBOR has 0 observations and 2 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: Input data set is empty.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK._TAB_ has 0 observations and 1 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK._TAB_.
NOTE: The data set WORK._TAB_ has 0 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Input data set is already sorted, no sorting done.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK.NEIGHBOR.
NOTE: There were 0 observations read from the data set WORK._TAB_.
NOTE: The data set WORK._TAB2_ has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Input data set is empty.
NOTE: The data set WORK._TAB2_ has 0 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK._TAB2_.
NOTE: There were 0 observations read from the data set WORK._TAB_.
NOTE: The data set WORK._TAB2_ has 0 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
NOTE: Input data set is empty.
NOTE: The data set WORK._TAB2_ has 0 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Table WORK._TAB_ has been dropped.
NOTE: Table WORK._HASHMAP_ has been dropped.
NOTE: Table WORK.NONB has been dropped.
NOTE: Table WORK.MAXZ has been dropped.
NOTE: Table WORK.NY2 has been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK.NEIGHBOR.
NOTE: The data set WORK.WMATRIX_COMPACT has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: IML Ready
WARNING: Data set WORK.NEIGHBOR is empty.
statement : USE at line 3335 column 12
WARNING: End of File reached.
statement : READ at line 3335 column 22
ERROR: (execution) Matrix has not been set to a value.
operation : [ at line 3335 column 64
operands : coord, , *LIT1002
COORD 0 row 0 col (type ?, size 0)
*LIT1002 1 row 1 col (numeric)
1
statement : ASSIGN at line 3335 column 52
ERROR: DO expression not given value.
statement : DO at line 3335 column 153
NOTE: The data set WORK._DIST_ has 0 observations and 3 variables.
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK._DIST_.
NOTE: The data set WORK.NEIGHBOR has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: Table WORK._DIST_ has been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK.NEIGHBOR.
NOTE: There were 0 observations read from the data set WORK.NEIGHBOR.
NOTE: The data set WORK.WMATRIX_COMPACT has 0 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: Input data set is empty.
NOTE: The data set WORK.WMATRIX_COMPACT has 0 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: IML Ready
WARNING: Data set WORK.NEIGHBOR is empty.
statement : USE at line 3348 column 87
WARNING: End of File reached.
statement : READ at line 3348 column 112
ERROR: (execution) Matrix has not been set to a value.
operation : MAX at line 3348 column 127
operands : idj
idj 0 row 0 col (numeric)
statement : ASSIGN at line 3348 column 122
ERROR: (execution) Matrix has not been set to a value.
operation : J at line 3348 column 137
operands : n, n, *LIT1002
n 0 row 0 col (type ?, size 0)
n 0 row 0 col (type ?, size 0)
*LIT1002 1 row 1 col (numeric)
0
statement : ASSIGN at line 3348 column 134
ERROR: (execution) Matrix has not been set to a value.
operation : J at line 3358 column 13
operands : n, n, *LIT1006
n 0 row 0 col (type ?, size 0)
n 0 row 0 col (type ?, size 0)
*LIT1006 1 row 1 col (numeric)
0
statement : ASSIGN at line 3358 column 7
ERROR: (execution) Matrix has not been set to a value.
operation : J at line 3358 column 28
operands : n, *LIT1007, *LIT1008
n 0 row 0 col (type ?, size 0)
*LIT1007 1 row 1 col (numeric)
1
*LIT1008 1 row 1 col (numeric)
0
statement : ASSIGN at line 3358 column 22
ERROR: DO expression not given value.
statement : DO at line 3358 column 37
ERROR: DO expression not given value.
statement : DO at line 3358 column 97
ERROR: Matrix w has not been set to a value.
statement : CREATE at line 3358 column 195
ERROR: No data set is currently open for output.
statement : APPEND at line 3358 column 218
ERROR: Matrix wpdr has not been set to a value.
statement : CREATE at line 3358 column 233
ERROR: No data set is currently open for output.
statement : APPEND at line 3359 column 8
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IML used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
@Reeza, maybe SAS version I'm running is lack of functions? while your have? I'm using 9.4TS, 1M3
Was running in SAS UE. Send me a DM and I’ll email the files tomorrow.
Hi Reeza,
I'm revisiting this post to complete to troubleshoot the error.
As you suggested, I contacted the author of the SUGI paper and I should define four mandatory variables (map, id, lat and long) from the tiger shapefile to the macro. I'm using tiger shapefile for New York at census tract level. Shp is not a valid extension to post but included the link to the data here, just in case.
I used NAME00 or TRACTCE00 (see attached screenshot of dataview) to define ID.However, both of these variables are not specific to unique combination of X and Y but INTPTLAT00 and INTPTLON00. And I used NAME00 or TRACTCE00 with INTPTLAT00 and INTPTLON00 whit no success again.
What is likely done wrong here? Any ideas or hints appreciated.
PROC MAPIMPORT OUT=newyork_ct
DATAFILE="...\tl_2010_36_tract00.shp";
run;
:
This is tiger file link
https://www.census.gov/cgi-bin/geo/shapefiles/index.php?year=2010&layergroup=Census+Tracts
/*Full error log with
%Wmatrix(map=Newyork_ct,id=TRACTCE00,lat=INTPTLAT00,long=INTPTLON00,out=neighbor); run;
*/
%Wmatrix(map=Newyork_ct,id=TRACTCE00,lat=INTPTLAT00,long=INTPTLON00,out=neighbor); run;
NOTE: There were 751298 observations read from the data set WORK.NEWYORK_CT.
NOTE: 746391 observations with duplicate key values were deleted.
NOTE: The data set WORK.NEWYORK_CT2 has 4907 observations and 15 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.14 seconds
cpu time 0.28 seconds
NOTE: There were 4907 observations read from the data set WORK.NEWYORK_CT2.
WHERE (INTPTLON00 not = ' ') and (INTPTLAT00 not = ' ');
NOTE: The data set WORK._HASHMAP_ has 4907 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: There were 4907 observations read from the data set WORK._HASHMAP_.
NOTE: The data set WORK.MAXZ has 1 observations and 3 variables.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
NOTE: There were 1 observations read from the data set WORK.MAXZ.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
2
NOTE: There were 4907 observations read from the data set WORK.NEWYORK_CT2.
NOTE: The data set WORK.NEWYORK_CT2 has 4907 observations and 15 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
6:182
ERROR: Type mismatch for key variable INTPTLON00 at line 4 column 194.
ERROR: Hash data set load failed at line 4 column 194.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 1 observations read from the data set WORK.NEWYORK_CT2.
WHERE (myx not = ' ') and (myy not = ' ');
WARNING: The data set WORK.NONB may be incomplete. When this step was stopped there were 0
observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: Variable TRACTCE00 not found.
ERROR: Variable MYID not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: The variable TRACTCE00 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._TAB_ may be incomplete. When this step was stopped there were 0
observations and 0 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: There were 0 observations read from the data set WORK._TAB_.
NOTE: The data set WORK._TAB_ has 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable TRACTCE00 not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: BY variable TRACTCE00 is not on input data set WORK.NEIGHBOR.
ERROR: BY variable TRACTCE00 is not on input data set WORK._TAB_.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._TAB2_ may be incomplete. When this step was stopped there were 0
observations and 1 variables.
WARNING: Data set WORK._TAB2_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
ERROR: Variable MYID not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable TRACTCE00 is not on file WORK._TAB_.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK._TAB_.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK._TAB2_ may be incomplete. When this step was stopped there were 0
observations and 1 variables.
WARNING: Data set WORK._TAB2_ was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable TRACTCE00 not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
NOTE: Table WORK._TAB_ has been dropped.
NOTE: Table WORK._HASHMAP_ has been dropped.
NOTE: Table WORK.NONB has been dropped.
NOTE: Table WORK.MAXZ has been dropped.
NOTE: Table WORK.NEWYORK_CT2 has been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: Variable myid is not on file WORK.NEIGHBOR.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.NEIGHBOR.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WMATRIX_COMPACT may be incomplete. When this step was stopped there were
0 observations and 1 variables.
WARNING: Data set WORK.WMATRIX_COMPACT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: The SAS/IML product with which IML is associated is either not licensed for your system or the
product license has expired. Please contact your SAS installation representative.
ERROR: Bad product ID for procedure IML.
ERROR: File WORK._DIST_.DATA does not exist.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.NEIGHBOR may be incomplete. When this step was stopped there were 0
observations and 0 variables.
WARNING: Data set WORK.NEIGHBOR was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
WARNING: File WORK._DIST_.DATA does not exist.
WARNING: Table WORK._DIST_ has not been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: Variable idi is not on file WORK.NEIGHBOR.
ERROR: Variable idj is not on file WORK.NEIGHBOR.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.NEIGHBOR.
ERROR: Variable idi is not on file WORK.NEIGHBOR.
ERROR: Variable idj is not on file WORK.NEIGHBOR.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.NEIGHBOR.
WARNING: The variable TRACTCE00 in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable cTRACTCE00 in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WMATRIX_COMPACT may be incomplete. When this step was stopped there were
0 observations and 1 variables.
WARNING: Data set WORK.WMATRIX_COMPACT was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
ERROR: Variable TRACTCE00 not found.
ERROR: Variable CTRACTCE00 not found.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: The SAS/IML product with which IML is associated is either not licensed for your system or the
product license has expired. Please contact your SAS installation representative.
ERROR: Bad product ID for procedure IML.
Oops, thanks for pointing out to a Licencing issue. I'll have to switch over to the other station with a good licence. In the meanwhile my colleague commented below and I was just gonna try her suggestions.
Hi there,
‘TRACTCE00’ is not unique within the state, only within the county. Try concatenating ‘COUNTYFP00’ with ‘TRACTCE00’ and using that for your ID.
I don’t see X & Y in the shapefile I downloaded from the Census that appears to be the one you are using.
If you are looking at the data in SAS, X & Y are variables SAS adds as part of the PROC MAPIMPORT procedure.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.