One-sample t-Test using SAS


For example, using the mpg data file, say we wish to test whether the average highway mpg (hwy) significantly differs from 25.  We can do this as shown below. Note all my codes have been test under SAS version 9.3.

proc ttest data=mpg h0=25;
  var hwy;

SAS output One sample t-test

The mean of the variable hwy for this particular sample of cars is 23.44, which is statistically significantly different from the test value of 25.  We would conclude that this group of cars has a significantly different mean on the highway mpg from 25.

If you believe that a one-sided test is more reasonable, you can specifies an lower or upper one-sided tests by adding sides=L(U) option, in which the alternative hypothesis indicates a mean smaller or greater than the null value.

proc ttest data=mpg h0=23 sides=U;
  var hwy;

SAS result one sample t-test one sideSince the P-value for this one-side test is not <.05, we would conclude that this group of cars doesn’t have a significantly higher mean on the highway mpg than 23.


See Also:

Do the same test in R

Leave a Reply

Your email address will not be published. Required fields are marked *