The one sample t test is used to compare the mean of a sample to some specific value. You set up a null hypothesis and test it against the alternative hypothesis. The alternative hypothesis can vary, based on whether you are performing a one sided or two sided t test. This post demonstrates how to perform simple one sample t tests in SAS by example.
Two Sided t Test Example
In the two sided case, we test the null hypothesis
(1)





Next, we evaluate the t statistic in both tales of a T Distribution with
We use PROC TTEST in SAS to assess the null hypotheses
proc ttest data=sashelp.class h0=60; sides=2 alpha=0.05; var height; run; |


To the right you can see the relevant t distribution for the two sided t test. The red area in the tails under the curve represent the p-value of 0.0624. This means that we reject the null hypothesis
One Sided t Test Example






However, if you suspect that if your null hypothesis does not hold, then the average height of students is either larger or smaller than your hypothesized mean, then you perform a one sided t test. You can do this in PROC TTEST as follows.
proc ttest data=sashelp.class h0=60 sides=u alpha=0.05; where sex='M'; var height; run; |


The only difference between the twp PROC TTEST steps is that we specify the SIDES=U in the latter step. This means that now, we test the null hypothesis
Summary
You can use the one sample t test to assess whether the population mean is equal to some specified mean with PROC TTEST. This is the easiest and most obvious way, but there are other procedures, that will yield the exact same result.
For a more thorough introduction to the concept, watch the youtube video Introduction To The One Sample T Test by JbStatistics.
For Statistics related posts, read Random Sampling Without Replacement in SAS.
Finally you can download the entire program from this post here.