Two Independent Sample t-Test using SAS

 

Let’s use the mpg data file and create a new categorical variable according to exist variable drv. The new drv_front variable is defined as 1 if drv = ‘f’ or 0 if not equal ‘f’.  We wish to test whether the mean for highway mpg (hwy) is the same for front-wheel drive car and other car (drv_front).

data mpg;
  set mpg;
  if drv = 'f' then drv_front = 1;
  else drv_front = 0;
run;
proc ttest data = mpg;
  class drv_front;
  var hwy;
run;

SAS result two sample t test

 

Notice SAS give two results assuming equal or unequal variance. And according to the result of test for equality of variance, the Pooled method should be used here. The results indicate that there is a statistically significant difference between the mean highway mpg for front-wheel drive and other type cars (p = <.0001).

 

See Also:

Do the same test in R

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *