data ex81; ***************************************************************** * Data are from Bettencourt & Miller (1996) on sex differences in * aggression as a function of provocation. For each study, there * are really two studies, one for provoked people and one for a * neutral condition. For both mini studies, the difference in * aggression for males and females is computed as a standardized * mean difference. There are 3 types of aggression measured: * (1) physical aggression, (2) [negative] evaluation, and (3) money * loss. These are coded 1 thru 3 under the variable 'aggr'. The * provoked group data is found under 'gne' and the neutral data is * found under 'gnc'. These are coded 1 (provoked) and 2 (neutral) * below. * This analysis is taken from Wang & Bushman (1999). ************************************************************************; input study aggr nne gne vne nnc gnc vnc; cards; 1 1 40 0.98 0.11 40 0.78 0.11 2 2 10 0.87 0.44 10 0.15 0.40 3 1 100 0.78 0.04 100 -0.58 0.04 4 1 20 0.64 0.21 20 0.37 0.20 5 2 120 0.53 0.03 60 0.08 0.07 6 1 40 0.52 0.10 40 0.63 0.11 7 1 40 0.46 0.10 40 0.52 0.10 8 1 240 0.42 0.19 240 -0.16 0.03 9 2 96 0.38 0.04 96 0.48 0.04 10 2 25 0.30 0.16 25 -0.15 0.16 11 1 194 0.28 0.02 194 0.49 0.02 12 1 12 0.21 0.33 12 0.15 0.34 13 1 40 0.19 0.10 40 0.07 0.10 14 1 10 0.00 0.40 10 0.00 0.40 15 2 80 0.00 0.05 80 0.00 0.05 16 2 34 0.00 0.12 34 0.00 0.12 17 2 40 0.00 0.10 40 0.00 0.10 18 2 40 0.00 0.10 40 0.00 0.10 19 2 39 -0.02 0.10 39 2.03 0.15 20 1 12 -0.02 0.33 12 0.08 0.34 21 1 12 -0.03 0.33 12 0.02 0.34 22 1 20 -0.09 0.20 20 1.13 0.23 23 1 12 -0.10 0.33 12 0.60 0.35 24 1 10 -0.11 0.40 10 2.31 0.67 25 3 60 -0.29 0.07 60 -0.02 0.07 26 2 72 -0.44 0.08 72 0.39 0.04 27 1 28 -0.67 0.20 27 0.40 0.15 28 3 40 -0.69 0.10 40 -0.10 0.10 29 2 20 -0.84 0.22 20 0.71 0.21 30 2 8 -1.19 0.59 8 0.61 0.52 31 1 10 -1.20 0.47 10 1.87 0.58 32 2 14 -2.52 1.65 14 0.31 0.29 *proc print; data ex81_2; set ex81; eff=gne; veff=vne; prov = 1; output; eff=gnc; veff=vnc; prov = 2; output; keep study aggr prov eff veff; data last; set ex81_2; keep eff veff aggr; %let vlist1=aggr; %let vlist2=aggr; %macro within(indata,outdata,eff,veff,ftname,nlevels); /********************************************************/ /* INDATA: Input data file name */ /* Input data file contains three variables: */ /* (1) EFF: Effect-size estimate */ /* (2) VEFF: The estimated variance for the */ /* effect-size estimate */ /* (3) ftname: Name of the factor included in */ /* the model */ /* NLEVELS: The number of levels of the factor */ /* FTNAME. For example, if the model */ /* contains two categorical variables, A and */ /* B, where A has three levels and B has two */ /* levels, the number of levels is 6 (2*3). */ /* In this example, one needs to create an */ /* artificial variable, FTNAME, that has six */ /* levels. */ /* OUTDATA: The output data file name. */ /* The output data file contains the information in */ /* the fixed-effects ANOVA table */ /********************************************************/ data tempin; set &indata; weight = 1 / &veff; data fate; %do i = 1 %to &nlevels; data in&i; set tempin; if (&ftname = &i); proc glm data=in&i noprint outstat=temp&i; class &ftname; model &eff = &ftname; weight weight; quit; %end; %do i = 1 %to &nlevels; data fate; set fate temp&i; %end; proc glm data=tempin noprint outstat=out1; class &vlist1; model &eff = &vlist2; weight weight; data out0 out2; set out1; if (_type_ = "SS1 ") then output out0; if (_type_ ^= "SS3 ") then output out2; keep df ss; data out3; set out1 fate; if (_type_ = "ERROR"); keep df ss; proc means data=out2 noprint; var df ss; output out=out4 sum=df ss; data &outdata; source = _n_; set out0 out3 out4; qstat=ss; pvalue = 1 - probchi(qstat,df); keep source qstat df pvalue; %mend within; %within(last,outdat,eff,veff,aggr,3); proc format; value aa 1 = 'Between Groups ' 2 = 'Within Groups ' 3 = ' Within 1 ' 4 = ' Within 2 ' 5 = ' Within 3 ' 6 = 'Corrected Total'; proc print data=outdat; format source aa.; data last2; set ex81_2; if (aggr=1) then trt=aggr+prov-1; if (aggr=2) then trt=aggr+prov; if (aggr=3) then trt=aggr+prov+1; %let vlist1=aggr prov; %let vlist2=aggr prov aggr*prov; %within(last2,outdat,eff,veff,trt,6); proc format; value aa 1 = 'Aggression ' 2 = 'Provocation ' 3 = 'Aggression*Provocation' 4 = 'Within ' 5 = 'Within 1 ' 6 = 'Within 2 ' 7 = 'Within 3 ' 8 = 'Within 4 ' 9 = 'Within 5 ' 10 = 'Within 6 ' 11 = 'Corrected Total '; proc print; format source aa.; run;