May 27, 2021 SAS
T-tests are performed to calculate the confidence limits of one sample or two independent samples by comparing their average and average differences. T he SAS procedure, called PROC TTEST, is used to perform t tests on a single variable and a pair of variables.
The basic syntax for applying PROC TTEST in SAS is:
PROC TTEST DATA = dataset; VAR variable; CLASS Variable; PAIRED Variable_1 * Variable_2;
The following is a description of the parameters used:
Below we see a sample t-test, where a variable horsepower estimate with a 95% confidence limit is found.
PROC SQL; create table CARS1 as SELECT make,type,invoice,horsepower,length,weight FROM SASHELP.CARS WHERE make in ('Audi','BMW') ; RUN; proc ttest data=cars1 alpha=0.05 h0=0; var horsepower; run;
When we execute the code above, we get the following results:
Pair the T test to test whether the two depending variables are statistically different from each other.
Since the length and weight of the car will depend on each other, we apply the pairing T test as shown below.
proc ttest data=cars1 ; paired weight*length; run;
When we execute the code above, we get the following results:
This t-test is designed to compare the averages of the same variables between two sets.
In our example, we compared the average variable horsepower between two different models ("Audi" and "BMW").
proc ttest data=cars1 sides=2 alpha=0.05 h0=0; title "Two sample t-test example"; class make; var horsepower; run;
When we execute the code above, we get the following results: