*file called influence1.sas in the influence directory;
*This makes the new influence variables from wnetwork and yvar;
libname workshop "C:\Users\kenfrank\Documents\MyFiles\COURSES\SEMINAR\SEMINAR\workshop 2012";
options nocenter;
options linesize=120;
options pagesize=58;
options linesize=78;
*a way of creating influence variables using proc means;
*w contains network data;
data w;
set workshop.talkt2;
relate=trelate2;
proc sort data=w;
*note: sorting by nominee the chosen, or i', to merge on the y-value;
by nominee;
*yvar1 contains belief or behavior at time 1;
data yvar1;
set workshop.indiv;
yvar1=use1;
nominator=nominee;
run;
proc sort data=yvar1;
by nominee;
*yvar2 contains belief or behavior at time 2;
data yvar2;
set workshop.indiv;
yvar2=use2;
run;
proc sort data=yvar2;
by nominator;
*constructing attractiveness if you want to use in for weights, less important;
proc means data=w noprint;
var relate;
by nominee;
output out=attract sum=attract;
*Now constructing the influence term;
data withy;
merge w yvar1(drop=nominator) attract;
by nominee;
if nominator ne nominee;
*If you want to include attractiveness as in
"Social capital and the implementation of computers ..." then set useattr=1;
useattr=1;
extra=1;
if useattr=1 then extra=attract;
infl=relate*yvar1*extra;
label infl="influence = wy";
run;
proc sort;
by nominator;
proc means noprint data=withy;
var infl;
by nominator;
output out=infl mean=totinfl;
*Now getting expansiveness;
proc sort data=w out=w2;
by nominator;
proc means data=w2 noprint;
by nominator;
var relate;
output out=expanse sum=expanse;
*yvar2 contains data at time 2;
data withinfl;
merge yvar2 yvar1 infl expanse attract(rename=(nominee=nominator));
by nominator;
drop nominee _type_ _freq_;
*note you must think about how to designate "no influence";
if totinfl=. then totinfl=0;
run;
proc reg data=withinfl;
*do you want an intercept?;
model yvar2=totinfl yvar1 / noint;
output out=withres r=resy2 p=prey2;
run;
proc reg data=withinfl;
*do you want an intercept?;
model yvar2=totinfl yvar1 tvalue1 ;
output out=withres r=resy2 p=prey2;
run;
proc print data=withres;
var yvar2 totinfl yvar1 resy2 prey2;
run;