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

Syntax

proc ttest data=name;

var <Option>

run;

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)

Syntax

proc ttest data=name;

class <Option>;

var <Option>;

run;

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)

Syntax

proc ttest data=name;

Paired v1*v2;

run;

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

Analytics is a vast field. At the one end, it overlaps with statistics and higher…

Do you love to explore and investigate information? Do you find spreadsheets to be a…

India has developed into the global hub for analytics. A large number of MNCs have…

International Business Machines Corp. Or IBM as it is popularly known recently announced its restructuring…

So you have got a job as an analyst in your dream company? Here are…

What's the sentiment on "sentiment analysis"? Is the field ready to take off?

## View Comments

I am from a pharma background with 3 yrs experience in core pharma. I am willing to make a switch over to analytics and need guidance on what courses would be the best to begin with