Table of Contents
Confidence intervals can be calculated in SAS using the PROC MEANS or PROC UNIVARIATE procedures. These procedures allow for the calculation of confidence intervals for a given variable, based on a specified confidence level. The confidence interval is a range of values within which the true population parameter is likely to fall with a certain level of confidence. SAS calculates the confidence interval by using the sample mean, standard deviation, and sample size. The resulting confidence interval can then be used to make inferences about the population parameter. Additionally, SAS offers the option to calculate confidence intervals for different types of data, such as continuous or categorical, making it a versatile tool for statistical analysis. Overall, SAS provides a reliable and efficient method for calculating confidence intervals and is commonly used in research and data analysis.
Calculate Confidence Intervals in SAS
A confidence interval is a range of values that is likely to contain a population parameter with a certain level of confidence.
This tutorial explains how to calculate the following confidence intervals in R:
1. Confidence Interval for a Population Mean
2. Confidence Interval for a Difference in Population Means
Let’s jump in!
Example 1: Confidence Interval for Population Mean in SAS
Suppose we have the following dataset that contains the height (in inches) of a random sample of 12 plants that all belong to the same species:
/*create dataset*/ data my_data; input Height; datalines; 14 14 16 13 12 17 15 14 15 13 15 14 ; run; /*view dataset*/ proc printdata=my_data;

Suppose we would like to calculate a 95% confidence for the true population mean height of this species.
We can use the following code in SAS to do so:
/*generate 95% confidence interval for population mean*/ proc ttestdata=my_data alpha=0.05; var Height; run;

The value for Mean shows the sample mean and the values under 95% CL Mean show the 95% confidence interval for the population mean.
From the output we can see that the 95% confidence interval for the mean weight of plants in this population is [13.4624 inches, 15.2042 inches].
Example 2: Confidence Interval for Difference in Population Means in SAS
Suppose we have the following dataset that contains the height (in inches) of a random sample of plants that belong to two different species:
/*create dataset*/
data my_data2;
input Species $ Height;
datalines;
A 14
A 14
A 16
A 13
A 12
A 17
A 15
A 14
A 15
A 13
B 15
B 14
B 19
B 19
B 17
B 18
B 20
B 19
B 17
B 15
;
run;
/*view dataset*/
proc printdata=my_data2;
Suppose we would like to calculate a 95% confidence for difference in population mean height between species A and species B.
We can use the following code in SAS to do so:
/*sort data by Species to ensure confidence interval is calculated correctly*/
proc sortdata=my_data2;
by Species;
run;
/*generate 95% confidence interval for difference in population means*/
proc ttestdata=my_data2 alpha=0.05;
class Species;
var Height;
run;

The first table we need to look at in the output is Equality of Variances, which tests whether or not the variance between each sample is equal.
Since the p-value is not less than .05 in this table, we can assume that the variances between the two groups is equal.
Thus, we can look at the row that uses Pooled variance to find the 95% confidence interval for difference in population means.
From the output we can see that the 95% confidence interval for the difference in population means is [-4.6895 inches, -1.1305 inches].
This tells us we can be 95% confident that the true difference between the mean height of plants in species A compared to species B is between -4.6895 inches and -1.1305 inches.
Since , this indicates that there is a statistically significant difference between the two population means.
The following tutorials explain how to perform other common tasks in SAS:
Cite this article
stats writer (2024). How can confidence intervals be calculated in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-confidence-intervals-be-calculated-in-sas/
stats writer. "How can confidence intervals be calculated in SAS?." PSYCHOLOGICAL SCALES, 25 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-confidence-intervals-be-calculated-in-sas/.
stats writer. "How can confidence intervals be calculated in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-confidence-intervals-be-calculated-in-sas/.
stats writer (2024) 'How can confidence intervals be calculated in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-confidence-intervals-be-calculated-in-sas/.
[1] stats writer, "How can confidence intervals be calculated in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can confidence intervals be calculated in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
