This tutorial explains how to perform a one sample t-test in SAS.
Example: One Sample t-Test in SAS
Suppose a botanist wants to know if the mean height of a certain species of plant is equal to 15 inches. She collects a random sample of 12 plants and records each of their heights in inches.
The heights are as follows: 14, 14, 16, 13, 12, 17, 15, 14, 15, 13, 15, 14
Use the following steps to conduct a one sample t-test to determine if the mean height for this species of plant is actually equal to 15 inches.
Step 1: Create the data.
First, we’ll use the following code to create the dataset in SAS:
/*create dataset*/ data my_data; input Height; datalines; 14 14 16 13 12 17 15 14 15 13 15 14 ; run; /*print dataset*/ proc print data=my_data;
Step 2: Perform a one sample t-test.
Next, we’ll use proc ttest to perform the one sample t-test:
/*perform one sample t-test*/ proc ttest data=my_data sides=2 alpha=0.05 h0=15; var Height; run;
The first table displays descriptive statistics for our sample, including:
- N (total observations): 12
- Mean (sample mean): 14.3333
- Std Dev (sample standard deviation): 1.3707
- Std Error (standard error, calculated as s/√): .3957
- Minimum (the minimum value): 12
- Maximum (the maximum value) 17
The second table displays the 95% confidence interval for the true population mean:
- 95% C.I. for μ: [13.4624, 15.2042]
The third table displays the t test statistic and corresponding p-value:
- t test statistic: -1.68
- p-value: 0.1201
Note: The t test statistic was calculated as:
- t test statistic = (x – μ) / (s/√n)
- t test statistic = (14.3333-15) / (1.3707/√12)
- t test statistic = -1.68
Recall that the one sample t-test uses the following null and alternative hypotheses:
- H0: μ = 15 inches
- HA: μ ≠ 15 inches
Since the p-value (.1201) is not less than .05, we fail to reject the null hypothesis.
This means we do not have sufficient evidence to say that the mean height of this certain species of plant is different than 15 inches.
The following tutorials explain how to perform other common statistical tests in SAS: