Comparing Two Independent Groups in SAS
Overview
A common situation in statistical analysis is one where you must compare
two groups of subjects to determine if there is a statistical difference in
the results. Depending on the situation, SAS has a number of procedures to
assist in this. This section will describe some of the procedures available
to you.
Introduction
In order to pick the appropriate test to use you must determine if you
have independent or paired groups. Independent groups contain data on two
unrelated samples. For example, comparison of male and female subjects
would be independent groups. Paired groups contain a pair a measurements for
each subject. The classical example is the before-and-after type of experiment
where you take data before some treatment and then after the treatment and
compare the two results.
Summarizing two Independent Groups
SAS provides two procedures, proc sort and proc means, that
can be used to summarize two independent groups. To summary the groups
using proc means the data must first be sorted. Below is an example
of what they would look like:
proc sort data=dataset;
by group-variable;
run;
proce means data=dataset;
by group-variable;
var variable-list;
New users to SAS always wonder when they are required to sort the dataset
before running a procedure. There is a simple way to remember, any procedure
where you use the keyword by must be sorted by that variable prior
to running the procedure (or in a previous step).
Example 10. Comparing two independent groups.
Often, a good preliminary way to compare groups is to graph the variable
by the group variable. This can easily be done is SAS with the
proc chart procedure. Below is an example of what this would look
like:
proc chart data=dataset;
vbar variable-list / group=group-variable;
run;
Example 11. Charting two independent groups.
Hypothesis Tests to Compare Two Groups
Using the T-test
The T-Test is one of the classical statistical tests used in
comparing groups. To use the T-Test, there are three assumptions for this
test:
- Observations are independent
- observations for each group are a sample from a population with a
normal distribution.
- variances for the two independent variables are about equal.
SAS provides the procedure proc ttest to perform simple T-Test.
The format of this is:
proc ttest data=dataset;
class group-var;
var variable-list;
run;
Example 12. Using proc ttest.
Back to Sas Index
Page
Author - Jack Suess
UMBC University Computing Services
Created - 1/17/96