Learn SAS T-Test – SAS PROC T Test
In our last tutorial, we study SAS Linear Regression, Now we will discuss another interesting statistical procedure SAS T-TEST that statisticians and scientists use.
Moreover, we learn SAS PROC T-test with an output. At last, we will see types of T-test in SAS Programming: SAS Simple t-test, SAS paired t-test and SAS two-sample t-test.
So, let’s start to learn SAS T-Test tutorial.
Stay updated with latest technology trends
Join DataFlair on Telegram!!
A t-test in SAS Programming is an analytical test used to determine if there is a significant difference between two sets of data, or if the average of a set of data differs significantly from a predicted value.
For example, consider that an analyst wants to study the amount that Gujaratis and Rajasthanis spend, per month, on clothing.
It would not be practical to record the spending habits of every individual (or family) in both states, thus a sample of spending habits is taken from a selected group of individuals from each state. The group may be of any small to moderate size.
The group may be of any small to moderate size — for this example, assume that the sample group is 200 individuals.
The average amount of Gujaratis comes out to 10000; the average amount for Rajasthanis is 20000. SAS t-test questions whether the difference between the groups is representative of a true difference between people in Gujarat and people in Rajasthan in general or if it is likely a meaningless statistical difference.
In this example, if, theoretically, all Gujaratis spent 10000 per month on clothing and all Rajasthanis spent 20000 per month on clothing, it is highly unlikely that 200 randomly selected individuals all spent that exact amount, respective to state.
Thus, it is safe to conclude that the difference between sample groups is indicative of a significant difference between the populations, as a whole, of each state.
SAS t-test looks at the t-statistic, the t-distribution and degrees of freedom to determine the probability of difference between populations.
SAS PROC TTEST
The SAS PROC TTEST is a procedure, which is used to carry out SAS t-test on a single variable and pair of variables.
SAS PROC T TEST Syntax-
PROC TTEST < options > ;
CLASS variable ;
PAIRED variables ;
BY variables ;
VAR variables ;
FREQ variable ;
WEIGHT variable ;
No statement can be used more than once. There is no restriction on the order of the statements after the PROC statement.
PAIRED variables identify the variables to be compared in paired comparisons. Use the PAIRED statement only for paired comparisons.
These PAIRED statements Yield these comparisons
PAIRED A*B; A-B
PAIRED A*B C*D A-B and C-D
PAIRED (A B)*(C D); A-C, A-D, B-C, and B-D
SAS One-Sample T-Test
Below we see one sample t-test SAS in which find the SAS t-test estimation for the variable weight_loss.
PROC TTEST DATA=CLINIC H0=4 ALPHA=0.1; VAR WEIGHT_LOSS ; TITLE 'TTEST OF H0: MEAN=4 FOR THE CLINIC GROUP'; RUN;
ALPHA=p – specifies the confidence interval. By default ALPHA=0.05
H0=m – requests tests against m instead of 0. By default H0=0.
Two Sample T-Test SAS
The SAS PROC TTEST procedure is used to test for the equality of means for a two-sample (independent group) SAS t-test.
- The typical hypotheses for a two-sample t-test are: Ho : µ𝟏 = µ𝟐 Ha : µ𝟏 ≠ µ𝟐
- Key assumptions: underlying the two-sample t-test are that the random samples are independent and that the populations are normally distributed with equal variances.
proc ttest data=sashelp.class; class cor; /* defines the grouping variable */ var age; /* variable whose means will be compared */ run;
SAS Paired t-test
When data is collected twice on the same subjects (or matched subjects) the proper analysis is a paired t-test in SAS(also called a dependent samples t-test). In this case, subjects may be measured in a before-after fashion.
Suppose your data contain the variables WBEFORE and WAFTER (before and after weight on a diet) for eight subjects. The appropriate analysis for this data is a SAS paired t-test.
DATA WEIGHT; INPUT WBEFORE WAFTER; DATALINES; 200 185 175 154 188 176 198 193 197 198 310 275 245 224 202 188 PROC TTEST; PAIRED WBEFORE*WAFTER; TITLE 'Paired t-test example'; Run;
This was all in SAS T-Test Tutorial. Hope you like our explanation.
So, today we learned what is SAS T-TEST, how T-Test is used for statistical analysis of data in SAS Programming. The syntax of creating SAS t-test, SAS paired t-test, SAS one sample t-test, and SAS two-sample t-test. For any queries post your doubts in the comments section below.