Two sample t-test with SAS

  1. The example and data set
  2. Setting up the data
  3. Analyzing the date with two sample t test
  4. Checking assumption for the method
  5. Reading the output
  6. Interpreting the results

Comparing test and control set

A common experiment design is to have a test and control conditions and then randomly assign a subject into either one. One variable to be measured and compared between two conditions. In the experiment, a new study method is compared to a standard one, and the reading score (after taking a study method) is recorded. The data set is “reading.csv”. Is there significant evidence that the new study method would get a different reading grade (on average) than the control method?

Setting up the data

Open the data set from SAS. If the data set is small, it can be manually input.

Analyzing the data, syntax

 
   proc ttest data=read;
 	title "Two sample t-test example";
 	class method; 
	var grade;
   run;

Checking assumptions

Two sample t-test assumes that

  1. The two groups of data are independent;
  2. The two groups of data follow normal distributions;
  3. The variance of two groups should be approximately equal.

Reading the output

          two sample t example                                                                                                       

                                       The TTEST Procedure
 
                                        Variable:  Grade

          Method         N        Mean     Std Dev     Std Err     Minimum     Maximum

          control        5     88.6000      7.3007      3.2650     80.0000     98.0000
          treatment      5       101.6      2.0736      0.9274     99.0000       104.0
          Diff (1-2)          -13.0000      5.3666      3.3941                        

  Method        Method               Mean       95% CL Mean        Std Dev      95% CL Std Dev

  control                         88.6000     79.5350  97.6650      7.3007      4.3741  20.9789
  treatment                         101.6     99.0252    104.2      2.0736      1.2424   5.9587
  Diff (1-2)    Pooled           -13.0000    -20.8268  -5.1732      5.3666      3.6249  10.2811
  Diff (1-2)    Satterthwaite    -13.0000    -21.9317  -4.0683                                 

                   Method           Variances        DF    t Value    Pr > |t|

                   Pooled           Equal             8      -3.83      0.0050
                   Satterthwaite    Unequal      4.6412      -3.83      0.0141

                                      Equality of Variances
 
                        Method      Num DF    Den DF    F Value    Pr > F

                        Folded F         4         4      12.40    0.0318



Interpreting the result

Based on the data, conduct a hypothesis test (with a 0.05 significance level) to see if there is evidence that the reading score is significantly different in the treatment than control group. Use α= 0.05.

The last part of the result is to check whether the variances of the two groups are equal. Some people use the simple rule here: if the probabiliyt is greater than 0.05, then the variances are equal and use the results for the equal variances. Other wise use the result for unequal variances. Since it it 0.0318, we read the p-value for unequal variance situation. The corresponding t-value = -3.83, and the p-value is 0.0141.
The conclusion is to reject the null hypothesis and say We have evidence that the the reading grade of two methods are significantly different.

Note that SAS only perform a two side test, meaning the hypothesis is to compare a significant difference between two groups. If one wants to test whether one group is greater(smaller) than the other, p-value must be divided by 2. For example, the p-value/2=0.0141/2=0.007 < 0.05, hence the concluse for the one side test is to reject the hypothesis and therefore the new method improve the grading score.