/* this program generates a simple peer influence dyad model on an example graph */ data a; input node female nonwhite a1 a2 a3 a4; cards; 1 1 0 2 3 4 . 2 0 0 1 3 7 . 3 1 1 1 2 7 5 4 1 1 1 5 . . 5 0 0 3 4 6 8 6 0 1 5 8 9 . 7 1 1 2 3 . . 8 1 1 5 6 9 . 9 0 0 6 8 . . ; run; data a; set a; eij=rannor(0); y=-1.8*nonwhite + 2.3*female +.1*(eij); run; proc iml; %include 'c:\moody\sas\programs\modules\adj.mod'; %include 'c:\moody\sas\programs\modules\uciwrite.mod'; use work.a; read all var{node} into node; read all var{female} into female; read all var{nonwhite} into nwt; read all var{a1 a2 a3 a4} into noms; read all var{y} into y; adjmat=adj(node,noms); adjid=adjmat[,1]; adjmat=adjmat[,2:ncol(adjmat)]; w=adjmat; do i=1 to nrow(w); w[i,]=w[i,]/w[i,+]; end; yt=y; print yt; do i=1 to 5; yt=w*yt; /* peer influenced Y */ end; print yt; samerce=j(nrow(adjmat),nrow(adjmat),0); samesex=samerce; simmat=samesex; ncomfnd=adjmat*adjmat; do i=1 to nrow(female); do j=1 to nrow(female); if i^=j then do; samerce[i,j]=(nwt[i]=nwt[j]); samesex[i,j]=(female[i]=female[j]); simmat[i,j]=abs(yt[i]-yt[j]); vstk=vstk//(i||j||adjmat[i,j]||samerce[i,j]||samesex[i,j]||simmat[i,j]||ncomfnd[i,j]); end; end; end; mattrib samerce format=1.0; mattrib samesex format=1.0; mattrib adjmat format=1.0; mattrib simmat format=4.3; print node adjmat samerce samesex simmat; id=node; create dydat from vstk [colname={sender rcver nom samerce samesex sim ncomfnd}]; append from vstk; file "c:\moody\classes\soc884\examples\UCINET\ex_ssex.dat"; call uciwrite(samesex,ID,node,2); file "c:\moody\classes\soc884\examples\UCINET\ex_srce.dat"; call uciwrite(samerce,ID,node,2); file "c:\moody\classes\soc884\examples\UCINET\ex_adj.dat"; call uciwrite(adjmat,ID,node,2); file "c:\moody\classes\soc884\examples\UCINET\ex_sim.dat"; call uciwrite(simmat,ID,node,2); file "c:\moody\classes\soc884\examples\UCINET\ex_ncom.dat"; call uciwrite(ncomfnd,ID,node,2); quit; proc reg; where sender>rcver; model sim = nom samerce samesex ncomfnd; run; proc print width=minimum; var sender rcver sim nom samerce samesex; run;