Summtable

From sasCommunity
Jump to: navigation, search

Summary / Purpose

Description

This program computes summaries for one or more groups and test statistics for differences between two or more independent samples. It can output well-formatted tables into RTF or PDF files. It is a major modification of the %summary macro written by Ryan Lennon (2009 Mayo Clinic College of Medicine).

Author(s)

Rocio Lopez, Composer/Author

Revision History

07/25/2013
Composed

Sample Macro Call (Defaults listed)

%summtable(data=, class=, con1=, con2=, con3=, cat1=, cat2=, ord1=,  subset=, colpct=1, pvalues=1, cutexact=50, totalcol=1, ncol=0, 
misscol=0,  adhoc=0, oddsratios=0,  unitscon1=, unitscon2=,   unitscon3=, sortby=, list=, out=_out_, rtfout=_rtf_, rtffile=, 
xmlfile=, pdffile=, odsmemo=0, desclabel=0, printptype=1, sdopt=1, tbltitle=, bdytitle=0, style=journal, page=portrait, printfn=1, 
addfn=, daytime=0, f1=__Countf., f2=__Estf., f3=__Pctf., f4=__Estf., pfmt=Pvaluef., lablen=$40, perfmt=5.1, cwidth1=85, cwidth2=, 
cwidth3=, printp=0, prints=2);

Macro Parameters

Required Parameters

ds
Dataset name
At least one of the following--
con1
Continuous variable list; report mean ± sd with ANOVA
con2
Continuous variable list; report median (min, max) with Kruskal-Wallis test
con3
Continuous variable list; report median [P25, P75] with Kruskal-Wallis test
cat1
Binary variable list; report N(%) for level=1 only with Pearson's chi-square/Fisher's Exact Test
cat2
Nominal variable list; report N(%) for all levels with Pearson's chi-square/Fisher's Exact Test
ord1
Ordinal variable list; report N(%) with Kruskal-Wallis test

Optional Parameters

sortby
Specify how to sort variables in the table
list
List for sorting variables if sortby = _list (no need to specify all)
out
Name for SAS db
rtfout
Name for SAS db
rtffile
Name for RTF file with final table (must be surrounded by " ")
pdffile
Name for PDF file with final table
desclabel
Use a descriptive variable labels for table (i.e. Age, mean ± SD vs. Age)
printptype
Attach superscript to denote type of test used (if =0 then footnote included)
sdopt
Use ± for con1 vars (if 2, then Mean (SD) used)
tbltitle
Title for table
bdytitle
Main SAS title/footnotes appear in body of RTF (1) or haders/footer (0)
style
Style of ods tables
page
Portrait vs. landscape page
printfn
Print default footnotes (depends on choices made)
addfn
Add your own footnote (no quotes)
daytime
Add a day/time stamp to files
f1
Format for counts (N, N missing)
f1
Format for means, sd, %tiles, min, max
f1
Format for %'s
f1
Format for ORs and CIs
pfmt
Format for pvalues
lablen
Length of variable labels
perfmt
Format for pvalues if prints=1 (print out db to output window)
cwidth1
Width for N , N missing, p-value columns in RTF file
cwidth2
Width for summary stats columns in RTF file
cwidth3
Width for variable label column in RTF file
printp
Print resutls of FREQ, MEANS, NPAR1WAY while running
prints
Print _out_ (1) or _rtf_ (2) data sets

Notes/Special Instructions

  1. It is a good idea to have all variables formatted, especially the CLASS variable
  2. CAT2 may contain SAS numeric or character variables, all other variable lists should contain SAS numeric variables.
  3. A variable should occur in only ONE display parameter list, i.e. don't put 'age' in both CON1 and CON2. You must create an identical variable with a different name to show different statistics.
  4. Variables which have all missing values will not be analyzed. Notification of this occurrence is sent to the SAS log.
  5. If NTOTALCOL=0, variable labels are flagged if there are missing values and a footnote is added stating # for each var.
  6. Default is to perform Exact tests for categorical variables if more than 50% of class have counts less than 5 but this can be manipulated with the CUTEXACT option. To supress exact tests then set CUTEXACT to a value greater than 100. A value of 0 would produce Exact tests only.
  7. If no class variable specified, TotalCol is ignored. If you want to print the N or N miss columns use NCOL=2 or MISSCOL=2 otherwise it will be ignored.
  8. The +/- sign from sdopt=1 will not print to output window with prints=2
  9. If ODSMEMO options is 1 then any option that controls the ods destination (style bodytitle etc.) will have no impact. Also, printp, rtffile, xmlfile and pdffile will be ignored.

Full Code

Link back to main page