R vs SAS ANCOVA

ANCOVA Comparison

The following table shows the types of One 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
ANCOVA using general linear model and lsmeans Yes Yes Yes GLM() function from sasLM with EMEANS=TRUE is the easiest to use and matches SAS

Comparison Results

Here is a table of comparison values between lm() from the stats package, GLM() from the sasLM package, and SAS PROC GLM:

Statistic lm() GLM() PROC GLM Match Notes
Type I, Sum sq, drug 293.6000 293.6000 293.6000 Yes
Type I, Sum sq, pre 577.897 577.8974 577.8974 Yes
Type III, Sum sq, drug 68.554 68.55371 68.55371 Yes
Type III, Sum sq, pre 577.897 577.89740 577.89740 Yes
LSmean drugA 6.71 6.714963 6.714963 Yes
LSmean drugD 6.82 6.823935 6.823935 Yes
LSmean drugF 10.16 10.161102 10.161102 Yes

Summary and Recommendation

The R ANCOVA analysis is comparable to SAS. Comparison between SAS and R show identical results for the datasets tried. The sasLM package GLM() function is very similar to SAS in the output produced. You can also match SAS using the stats package with the lm() function and various modification functions. See the R page for further information.

References

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

R GLM() documentation: https://cran.r-project.org/web/packages/sasLM/sasLM.pdf

SAS PROC GLM documentation: https://documentation.sas.com/doc/en/statug/15.2/statug_glm_syntax01.htm