University of Rochester Medical Center
SearchDirectoryNewsEventsStrong HealthURMC Home
 

SAS Helpful Hints

Biostat Macro Library

Quick Tabulations

%Tabulate and %TableFreq reside in the departments SAS Macro Library and are enabled with the following SAS statements:

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

%Tabulate tabulates continous variables and their changes from baseline and washout, by group and visit. Four groups of statistics are available: Pub(Publication style:Mean(Std)), Brief(N,Mean,Std), Short(N,Mean Std,Min,Max) or Long(N,Mean,Median,Std,Stderr, Min,Max). %Tabulate automatically adjusts the dimensions of the table to fit nicely on a page.

%TableFreq tabulates discrete variables and changes from baseline and washout, by group and visit. The table includes the N and % for each variable in the VarList. %TableFreq automatically adjusts the dimensions of the table to fit nicely on a page. Publication style, N(%), is available by putting "Pub" as the outfile. The output is directed to the output window.

You may specify a minimum percentage of enrolled subjects to be included to eliminate sparsely populated cells in the table. If there is not enough data at a visit, it may not be useful to tabulate. All the data will be included if DropPct is set to 0 [zero].

Syntax:
%Tabulate(dataset,who,groups,visit,baseline,washout,droppct,stats,varlist,outfile);
%TableFreq(dataset,who,groups,visit,baseline,washout,droppct,varlist,outfile);
    dataset:    Dataset to use.
    who:        Subject ID.
    groups:    Groups(All Numeric).
    visit:         Time variable: visit, week, month.(Numeric)
    baseline:   Baseline visit(Numeric Constant).
    washout:   Washout visit(Set equal to baseline if there is no washout.)
    stats:    pub: (Mean(Std))
                brief: (N Mean Std)
                short: (N Mean Std Min Max)
                long: (N Mean Std Min Max StdErr Median)
    droppct:    Excludes data where N<DropPercent of enrolled(0-100).
    varlist:       List of variables to Tabulate(All Numeric).
    outfile:      Output file.

Example:
%Tabulate(work.A,id,Gender Treatment,visit,0,0,20,Short,A B C D E F,C:\table.out);
%TableFreq(work.A,id,Gender Treatment,visit,0,0,20,A B C D E F,C:\table.out);

%Tabulate and %TableFreq are best used in conjuction with %CleanTable:

%Let output1=C:\table.out;
%Tabulate(work.A,id,Gender Treatment,visit,0,0,20,Short,A B C D E F,&output1);

%Let output2=C:\table.lst;
%CleanTable(&output1,&output2);

The number of digits displayed in publication mode can be changed by defining a macro variable named “Digits” before calling the procedure:

%Let Digits=3;

Several styles of HTML output can be requested by defining a macro variable named "HtmlStyle" before calling the procedure:

%Let HtmlStyle=URbw1;

Available styles include: URbw1, URpp1, BarrettsBlue, Beige, Brick, Brown, D3D, Default, Minimal, NoFontDefault, Printer, RTF, Statdoc, Theme, FancyPrinter, SansPrinter, SasdocPrinter and SerifPrinter.

The HTML output may be directed to a file by defining a macro variable named "HtmlFile" before calling the procedure:

%Let HtmlFile=c:/test.html;

The size of the text in the HTML output may be changed by defining a macro variable named "HtmlSize" before calling the procedure:

%Let HtmlSize=-1; *or;
%Let HtmlSize=+1;

The resulting output is best read and formatted with Microsoft Word.

Output:

 

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