UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS Code Fragments
Simple Contrast in 3 way anova

* make data for a*b*c 3 by 2 by 3 design with ;
* factor c repeated
data test;
  do a = 1 to 3;
    do b = 1 to 2;
      do c = 1 to 3;
        x = ranuni(-1);
		output;
      end;
	end;
  end;
run;

* test bcomp (b1 vs b2) at a2 c3 ;
* note order of variables in class statement ;
* determines how quickly vars change in contrast ;
* statement. a changes slowest, then b, and c changes ;
* fastest ;
proc mixed data=test;    
  class a b c ; 
  model x = a b c a*b a*c b*c  a*b*c  ;    
  contrast 'bcomp at a2 c3'  a 0 0 0 
                             b 1 -1 
                             c 0 0 0 
                             a*b 0 0 
                                 1 -1 
                                 0 0 
                             a*c 0 0 0 
                                 0 0 0 
                                 0 0 0 
                             b*c 0 0  1 
                                 0 0 -1 
                           a*b*c 0 0 0
                                 0 0 0 

                                 0 0  1 
                                 0 0 -1

                                 0 0 0 
                                 0 0 0 ;
run; 

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California