Descriptive Statistics

SAS Code Examples

The BSC developed this SAS code to demonstrate the calculation of summary statistics using three SAS macros: %DSTMAC (Fenchel, McPhail, and VanDyke 2011), %UNI_CAT (Liu et al. 2019), and %ggBaseline (Gu et al. 2018). Analyses are stratified by two variables (“trt” and “sex”).

Summary statistics include:

  • means ± standard deviations for continuous variables
  • N (%) for categorical variables

Statistical hypothesis tests include:

  • Parametric Test: T-Test/ANOVA for continuous variables
  • Parametric Test: Likelihood Ratio Chi-Square Test for categorical variables
  • Non-parametric Test: Kruskal-Wallis Test for continuous variables
  • Non-parametric Test: Fisher’s Exact Test for categorical variables

See the GitHub repository for the example code, dataset, and output.

References

Fenchel, Matthew C., Gary L. McPhail, and Rhonda D. VanDyke. 2011. “A Lazy Programmer’s Macro for Descriptive Statistics’ Tables.” In MidWest SAS Users Group. https://www.mwsug.org/proceedings/2011/stats/MWSUG-2011-SA19.pdf.

Gu, Hong-Qiu, Dao-Ji Li, Chelsea Liu, and Zhen-Zhen Rao. 2018. “%ggBaseline: a SAS macro for analyzing and reporting baseline characteristics automatically in medical research.” Annals of Translational Medicine 6 (August): 326–26. https://doi.org/10.21037/atm.2018.08.13.

Liu, Yuan, Dana C. Nickleach, Chao Zhang, Jeffrey M. Switchenko, and Jeanne Kowalski. 2019. “Carrying Out Streamlined Routine Data Analyses with Reports for Observational Studies: Introduction to a Series of Generic SAS ®Macros.” F1000Research 7. https://doi.org/10.12688/f1000research.16866.2.