/* this program runs a simple cluster analysis on the distance matrix of the school network as a way of finding in-groups. */ 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 spanmod = c:\jwm\sas\modules\; proc iml; reset storage = in1.netstore; load amatis amatis_id; %include "&spanmod.adjlist.mod"; %include "&spanmod.distlst.mod"; %include "&spanmod.bfs.mod"; symmat=(amatis+amatis`)>0; /* sym vers of the adj. matrix */ syslst=adjlist(symmat); dmat=distlst(syslst); dmat=choose(dmat=.,max(dmat)+1,dmat); dmat=dmat-diag(dmat); chk=dmat[1:10,1:10]; mattrib chk format=1.0; print chk; dmat=amatis_id||dmat; create work.dmat from dmat [colname={id}]; append from dmat; quit; data dmat (type=distance); set dmat; run; proc contents data=dmat; run; proc cluster data=dmat method=ward out=dtree; id id; run; proc tree data=dtree ncl=20 out=dclust; id id; run; proc sort data=dclust; by id; run; /* write the file out to PAJEK and plot */ data dum; file 'c:\jwm\conferences\columbia\workshop\distclust.clu'; put "*Vertices 255"; run; data dclust; set dclust; file 'c:\jwm\conferences\columbia\workshop\distclust.clu' mod; put cluster; run;