R vs SAS Two Sample T-Test

Two Sample t-test Comparison

The following table shows the types of Two Sample t-test analysis, the capabilities of each language, and whether or not the results from each language match.

Analysis Supported in R Supported in SAS Results Match Notes
Two sample Student’s t-test Yes Yes Yes In Base R, use t.test() function with paired = FALSE and var.equal = TRUE
Two sample Welch’s t-test Yes Yes Yes In Base R, use t.test() function with paired = FALSE and var.equal = FALSE

Comparison Results

Student’s T-Test

Here is a table of comparison values between t.test(), proc_ttest(), and SAS PROC TTEST:

Statistic t.test() proc_ttest() PROC TTEST Match Notes
Degrees of Freedom 30 30 30 Yes
t value -0.6969002 -0.6969002 -0.6969002 Yes
p value 0.4912306 0.4912306 0.4912306 Yes

Welch’s T-Test

Here is a table of comparison values between t.test(), proc_ttest(), and SAS PROC TTEST:

Statistic t.test() proc_ttest() PROC TTEST Match Notes
Degrees of Freedom 29.69359 29.69359 29.69359 Yes
t value -0.6969002 -0.6969002 -0.6969002 Yes
p value 0.4912856 0.4912856 0.4912856 Yes

Summary and Recommendation

For the Student’s T-Test, the R two sample t.test() and procs proc_ttest() capabilities are comparable to SAS. Comparison between SAS and R show identical results for the datasets tried.

Likewise, for the Welch’s T-Test, the R two sample t.test() and procs proc_ttest() capabilities are comparable to SAS. Comparison between SAS and R show identical results for the datasets tried.

References

R t.test() documentation: https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/t.test

R proc_ttest() documentation: https://procs.r-sassy.org/reference/proc_ttest.html

SAS PROC TTEST Two Sample analysis documentation: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_ttest_examples01.htm