/* this program loads the school data and the school network, and creates some simple node-level degree measures. */ /* read in the base data */ libname in1xpt xport 'c:\jwm\conferences\columbia\workshop\sdatcln.xpt'; libname in1 'c:\jwm\conferences\columbia\workshop\'; /* bring in the base school data */ data sdat; set in1xpt.sdatcln; run; /* load the network and create the measures */ %let spandir = c:\jwm\sas\modules\; proc iml; reset storage = in1.netstore; load amatis amatis_id; /* get some modules to simplify things */ %include "&spandir.adjlist.mod"; %include "&spandir.distlst.mod"; %include "&spandir.closeness.mod"; %include "&spandir.bfs.mod"; %include "&spandir.egonet.mod"; %include "&spandir.density.mod"; indeg=amatis[+,]; /* sum of the columns */ indeg=indeg`; outdeg=amatis[,+]; /* sum of the rows */ symchk=(amatis+amatis`); recip=(symchk=2); precip=recip[,+]/outdeg; /* proportion of ties ego sent that are reciprocated */ symnet=(symchk)>0; /* ij=1 if i-->j, or j-->i */ totdeg=symnet[,+]; /* turns out is is faster to get distance measures, and thus closeness centrality, on an adjacency list version of the net. Convert that here, then get a distance matrix, then get closeness centrality */ symlst=adjlist(symnet); dstmat=distlst(symlst); ccent=closeness(dstmat); /* first col is centrality, 2nd is centralization */ /* let's also calculate ego-network density. This is the proportion of possible ties among ego's alters that are present. I'll use the "send & recieve " network */ nr=nrow(amatis); enetden=j(nr,1,.); /* initialize value to . */ do i=1 to nr; if totdeg[i]>1 then do; /* only makes sense for ego nets greater than 1 */ eni=egonet(i,amatis,'SOR'); /* pulls out the row/col numbers of ego's network */ eni=remove(eni,1); /* take ego out of the network */ eneti=amatis[eni,eni]; /* construct ego net adj mat */ enetden[i]=density(eneti); /* calc density */ end; end; outd=amatis_id||indeg||outdeg||totdeg||ccent[,1]||precip||enetden; create work.netstats from outd [colname={nid indeg outdeg totdeg clscent precip eden}]; append from outd; quit; data sdat; merge sdat netstats; isolate=0; if totdeg=0 then isolate=1; run; proc logistic descending data=sdat; model s64 = female s3 white isolate; run; quit; /* try the reciprocity stat. Note that lots of values are missing, since the score is undefined if outdegree = 0,we could change those values to 0, but you get the idea... */ proc logistic descending data=sdat; model s64 = female s3 white precip; run; quit; proc logistic descending data=sdat; model s64 = female s3 white eden; run; quit;