University of Rochester Medical Center
SearchDirectoryNewsEventsStrong HealthURMC Home

SAS Helpful Hints

Biostat Macro Library

Mass Production of Observed & Delta BoxPlots

%Boxplot resides in the departments SAS Macro Library and is enabled with the following SAS statements:

Libname biostat '\\BIO2\example\SASMacrosWindows';
Options Mstored SasMstore=biostat;

%Boxplot create boxplots of observed values and their changes from baseline for a list of given variables. This procedure uses all data points in the dataset, and combine all visits as one boxplot. This is an easy way to determine if the data is uniformly distributed and identifies if there are any outliers. Variables with similar ranges are plotted on the same graph. You may specify the maximum number of scales on a graph, and a tolerance (0-100%) to group variables by their range. Available plot styles are BlackWhite, Color (white background) or PowerPoint (blue frame, gold trim, black background). Graphs are displayed individually and in pairs, 2, 4 or 16 to a page. A grouping variable may be supplied to separate or jitter the boxes.

Suggestion: Use short labels on the variables to be plotted so the labels on the X axis are printed horizonaly instead of vertically.

Syntax:
%Boxplot(dataset,who,group,varlist,visit,baseline,maxperplot,tolerance,style,replay);
    dataset:       Dataset to use.
    who:           Subject ID.
    group:         Treatment group.
    varlist:         List of variables to Boxplot(All Numeric).
    visit:            Time variable: week day or visit(Numeric).
    baseline:      Baseline visit(Numeric Constant).
    maxperplot: Maximum number of scales on a graph(Numeric Constant).
    tolerance:    Tolerance Pecentage(0-100) (70 is a good start.)
        (If max(B)*tolerance/100<max(A) Then Share Graph, Else start new graph)
    style:           BlackWhite, Color or PowerPoint.
    replay:         Number of graphs to display on a page(2, 4 or 16).

Example:
%Boxplot(work.A,id,,A B C D E,visit,0,6,70,PowerPoint,4);

The default colors may be changed by defining a macro variable named “Colors”:

%Let Colors=Background_color Foreground_color Box1_color Box2_color…;
%Let Colors=Blue Yellow White Pink Green;

The default font of centx may be changed on all text by defining a macro variable named “Font”:

%Let Font=Simplex;

The position of the legend may be changed by defining a macro variable named "LegendOption":

%Let LegendOption=Position=(Inside Top Left) Across=2 Down=2;

This procedure creates a graphics catalog named “work.mplot”. The graphics catalog may be cleared by closing the graph window and running the following code.

Proc Datasets Library=work Memtype=Catalog;
    Delete mplot;
Run;

If you are running SAS interactively, this procedure will always replay the first set of graphs in the catalog. You may wish to reset the catalog between each procedure call.

Output:


Please send your comments and suggestions about this web page to A. Watts (watts@bst.rochester.edu)