Rabidwolff's Alehouse
"Your place for fun and knowledge."
HOME | Quotes | SAS | C# | BEER



Basics
FORMATS
INFORMATS
DATETIME
ATTRIB
LENGTH
FORMAT
INFORMAT
LABEL
JOINS
OPERATORS

Statements
RETAIN
FIRST.
LAST.

Procedures
PROC SORT
PROC COPY
PROC CPORT
IF ELSE
PROC REPORT

Functions
CAT
CATS
CATT
CATX

CDISC
Random Q & A

CDISC
CDISC Info

Coded Tools
XML Output
Examples

PROC REPORT

PROC REPORT allows you to display or summarize data from a SAS dataset with various controls on how you want it displayed. Commonly used with ODS to output to PDF, CSV, HTML, etc.

Example Code and Output:


Special Notes:
For HTML ODS output, the FORMAT option will not actually increase cell width past the set cell value (use style property to control it then). The WIDTH, SPACING, HEADSKIP, and HEADLINE work only with default LISTING output.

PROC REPORT Options

The PROC REPORT procedure allows for certain procedure wide options that can be applied.
"PROC REPORT DATA=WORK.TEST [options];"

Example Description
NOWD Can be used for windows environment only. Default is to display output in a window, this option (or using NOWINDOWS) will not show output to a new window.
SPLIT='*' The default is '/', otherwise specify a character to automatically split headers on to a new row.
HEADLINE Adds an underline between the headers and data rows
HEADSKIP Leaves on one blank line between the headers and data rows

DEFINE Options

The DEFINE statement allows for column display customizations.
"DEFINE variable_name / [options];"

Example Description
'Weight' Default is the variable name to be displayed as the column header. Adding quoted text will overwrite and display as the column. The header will be split by spaces if presnet first, then within text depending on the lenght or width of the column.
CENTER The column justification can be specified between CENTER, LEFT, or RIGHT. The default is LEFT for character and RIGHT for numeric variables.
FORMAT=z3. Applys a SAS format to display the output.
SPACING=3 Adds blank spaces between the selected column the column directory to it's left. Leaving this option off will default to 2 spaces.
WIDTH=10 Specifies number of characters wide a column will be. Default is width per format. Specifying a width smaller than the data length will cause '*' to appear. Specifying the width affects how the header appears as well.

PROC REPORT Variable Usages

PROC REPORT variables are set to one of six usage types. These control how the procedure handles the variable and it's values are displayed the output.

DISPLAY

Default for character variables if not set. Simply displays the value of the variable with any style or formatting that is applied.

NODISPLAY

Column will not be visible in the output even though it is in the COLUMN statement.

ORDER

ORDER variables will be ordered left to right, overwriting any pre-procedure order. The default order is ASCENDING. The option DESCENDING can be added to reverse that order. Note that only the first occurrence of an ORDER variable value is displayed for a set of values being the same over 2 or more records.

GROUP

GROUP variables are used for creating summary reports. When GROUP variables are used, repeating values of the same are consolidated together. When this happens, any SUM variables are automatically summed together. Note, all character variables must be set as a GROUP, ANALYSIS, ACROSS, or COMPUTED variable to summarize. If not, GROUP variables are treated as ORDER variables.

Example using above test dataset grouping Gender:


ANALYSIS

ANALYSIS variables can be set to several different statistical usages. SUM is actually an ANALYSIS variable but is the default for a numeric type. The table below describes the summaries the most used.

Statistic Description
CSS Corrected sum of squares
USS Uncorrected sum of squares
CV Coefficient of variation
MAX Maximum value
MEAN Average
MODE Most Frequent Value
MIN Minimum value
N Total nonmissing value observations
NMISS Total missing value observations
RANGE Range
STD Standard deviation
STDERR Standard error of the mean
SUM Sum
SUMWGT Weight values summed
PCTN % frequency or value to total
PCTSUM % record sum to total sum
VAR Variance

ACROSS

ACROSS variables group similar values horizontally by frequency count per unique value.

Example using above test dataset with across for Gender:


COMPUTE Block

The COMPUTE block allows for setting/modification of values during the PROC REPORT processing of data. A new variable (not in the input dataset) can be added to the COLUMN and DEFINE statements and the value set in the COMPUTE block.


Rabidwolff Industries | Establisted: 10/15/2011 | Version: 4 8/4/2012 | Page Last Generatated: 9/25/2021 4:09:38 PM