* This is file DRINK.SAS ; title 'drinking and agression data--two factor with rpt meas on one factor'; * As set up, this file will analyze anti-social personality ; * and drinking data for the AGGRESSION personality ; * score (Table 9-8). To use with other scores (anger, depression, ; * well-being) edit infile appropriately and delete the ; * last section for reading in and analyzing missing data ; * additional data files are drinkang.dat (Table C-15) and ; * drinkdep.dat (Table C-16). ; * Create data set for AGGRESSION Score: no missing data ; DATA drinkagg; infile drinkagg; input S D A PASP1 PASP2 PASP3 PASP4 PASP5 PASP6 PASP7 PnonASP1 PnonASP2 PnonASP3 PnonASP4 PnonASP5 PnonASP6 PnonASP7 Group Subject; DA=D*A; LABEL S='Aggression score' D='Dummy variable =-1 if drinking' A='Dummy variable =-1 if ASP alcoholic' DA='Interaction of D and A' PASP1='subject dummy for first ASP subject' PASP7='subject dummy for seventh ASP subject' PnonASP1='dummy for first non-ASP subject' PnonASP7='dummy for seventh non-ASP subject'; * Analysis of variance computed with regression and ; * dummy variables ; proc REG data=drinkagg; model S=PASP1-PASP7 PnonASP1-PnonASP7 A D DA/SS1; * Do analysis of variance with GLM procedure and the ; * RANDOM subcommand to specify a 3 way problem with the ; * subjects factor (nested in ASP group, A) delcared as ; * random. ; proc GLM; Class A D Subject; model S = A|D Subject(A)/Solution; random Subject(A); * Modify data set to get it into form needed for ; * repeated measures using ANOVA or GLM and the ; * REPEATED subcommand ; DATA; set; keep S A D Subject; * First sort the data set by the child aggression ; * factor, A, and Subjects: then transpose so that ; * each ROW of the data set contains the repeated ; * measurement over the drinking factor, D ; proc sort; by A Subject; proc transpose; Var S; by A Subject; data anov; set; keep A COL1 COL2; rename COL1=D0 COL2=D1; * Traditional ANOVA on transposed data set ; proc ANOVA data=anov; class A; model D0-D1=A; repeated D/NOM; * Create data set for AGGRESSION Score: with MISSING data ; * Delete this section when analyzing other scores ; DATA drinkagm; infile drinkagm; input S D A PASP1 PASP2 PASP3 PASP4 PASP5 PASP6 PASP7 PnonASP1 PnonASP2 PnonASP3 PnonASP4 PnonASP5 PnonASP6 PnonASP7 Group Subject; DA=D*A; LABEL S='Aggression score' D='Dummy variable =-1 if drinking' A='Dummy variable =-1 if ASP alcoholic' DA='Interaction of D and A' PASP1='subject dummy for first ASP subject' PASP7='subject dummy for seventh ASP subject' PnonASP1='dummy for first non-ASP subject' PnonASP7='dummy for seventh non-ASP subject'; * Analysis of variance on missing data ; * Ask for expected mean squares ; proc GLM; Class A D Subject; model S = A|D Subject(A)/Solution; random Subject(A); lsmeans A D A*D/stderr pdiff; * Analysis of variance using dummy variables, repeat with ; * different order of effects to compute SS: In this case, ; * we can get sums of squares, but cannot do complete ; * analysis without expected mean squares from GLM above ; proc REG data=drinkagm; model S=PASP1-PASP7 PnonASP1-PnonASP7 A D DA/SS1; model S=PASP1-PASP7 PnonASP1-PnonASP7 D DA A/SS1; model S=PASP1-PASP7 PnonASP1-PnonASP7 A DA D/SS1;