# R vs SAS Paired T-Test

# Paired t-test Comparison

The following table shows the types of Paired 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 |
---|---|---|---|---|

Paired t-test, normal data | Yes | Yes | Yes | In Base R, use `paired = TRUE` on `t.test()` function |

Paired t-test, lognormal data | Maybe | Yes | NA | May be supported by envstats package |

## Comparison Results

### Normal Data

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 | 11 | 11 | 11 | Yes | |

t value | -1.089648 | -1.089648 | -1.089648 | Yes | |

p value | 0.2992 | 0.2992 | 0.2992 | Yes |

### Lognormal Data

Since there is currently no known support for lognormal t-test in R, this comparison is not applicable.

# Summary and Recommendation

For normal data, the R paired t-test capabilities are comparable to SAS. Comparison between SAS and R show identical results for the datasets tried. The **procs** package `proc_ttest()`

function is very similar to SAS in the syntax and output produced. `proc_ttest()`

also supports by groups, where `t.test()`

does not.

For the lognormal version of the t-test, it does not appear to be supported in the **stats** or **procs** package. It may be supported in the **envstats** package. More exploration is needed to determine whether this package will produce the expected results, and whether the results will match SAS.

# 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`

Paired analysis documentation: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_ttest_syntax08.htm