Hypothesis Testing Types of t-tests in SAS

This post has been written by Jigsaw Faculty Kafeel Basha

Let me begin this article by explaining exactly what a t- test is. I will then explain when we can use the t- test and then go on to tell you all about the procedure we can use to perform the t- test using the language of SAS.

Well, a t-test is a statistical significance that indicates whether or not the difference between two sample means, most likely reflects a real difference in the population from which the groups were sampled. In simple words, t- test is used to find the mean difference between population mean and sample mean.

When can we apply t- test?

We can apply the t- test when we have a sample size n<30, population mean, sample mean and sample standard deviation.

Procedure used to perform t- test in sas: Proc ttest

Type t- test using SAS

SAS Code for t- test: One sample


proc ttest data=name;

var <Option>


Where “name” is the data set name used for the test and “<Option>” gives the variables used for the t test ie “option=variable name” where the sample data is stored. Each variable that was listed on the var statement will have its own line in this part of the output.  If a var statement is not specified, proc ttest will conduct a t-test on all numerical variables in the dataset.

SAS Code for t- test: Two sample (Independent Sample)


proc ttest data=name;

class <Option>;

var <Option>;


Here class statement subgroup the two different sample and we have to specify the variable name where the observation for both the samples are stored.

Note: We have to arrange the data before performing two sample test.

(Example given, Where X and Y are two samples for T test)

SAS Codes for T test: Paired (Dependent Sample)


proc ttest data=name;

Paired v1*v2;


Where v1 and v2 are the dependent variables.

Output of T test:

  • This first table provides means, standard deviation, min and max for each group and the mean difference.
  • The next table provides 95% Confidence Limits on both the means and Standard Deviations, and the mean difference using both the pooled (assume variances are equal) and Satterthwaite (assume variances are not equal) methods.
  • Before deciding the appropriate ttest we should look for if the variances for the two groups are equal. If the p-value (Pr>F) is less than 0.05, you should assume UNEQUAL VARIANCES.
  • Choose the Satterthwaite t-test, if we have unequal variance. If the variances were assumed equal, you would report the Pooled variances t-test.
  • The last step is according to p value we get, we accept or reject the null.
  • When you use the ODS GRAPHICS ON; option, we get graph which provides a visual comparison of the means (and distributions) of the two groups.
  • Also we can see why the test for equality of variances equal or unequal.

Note: For paired t test Pooled and Satterthwaite methods are not required as the variables are dependent.

Related Articles:

Logistic Regression in SAS
5 Popular Tools for Data Visualization
Understanding Dummy Variable Traps in Regression
Popular Applications of Linear Regression for Businesses

Interested in learning about other Analytics and Big Data tools and techniques? Click on our course links and explore more.
Jigsaw’s Data Science with SAS Course – click here.
Jigsaw’s Data Science with R Course – click here.
Jigsaw’s Big Data Course – click here.

Related Articles

Please wait while your application is being created.
Request Callback