Presentation on theme: "Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth."— Presentation transcript:
Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth
Why create a columnar output from a data set. n For own use. n To show others at a meeting. n To put in a standardized regulatory report. n To put in a publication. The above are ranked in approximately increasing effort required to create the report. Author’s Opinion: It is the neatest, most heuristic way to present a data set.
PROC CONTENTS for ECGTEST 57 Variables 28 Observations
Solution 1: Default PROC PRINT Advantages: n Easy and Neat for Narrow Data Set n Can Use ID and VAR Statements. Disadvantages: n Virtually No Beautification Options n Doesn’t Work for a Wide Data Set n Wraps Neatly but One Can’t Control Wrapping with the exception of increasing the page size. n Wide Columns are Truncated.
Default PROC PRINT
Default PROC REPORT
Solution 2: Use a Default PROC REPORT with NOWD (Required in Batch) Option Advantages n Output is columnar. n Small number of variables fit on a page. Disadvantages n Rows are not identified for multiple pages. n Spacing between columns is uneven. n Column labels split unattractively. n Column order isn’t optimum. n Wide columns cause program to bomb.
PROC REPORT Defaults and Properties n PROC was designed to run interactively. n Labels are used as column headers. n Variables are in position order. n Spacing is 2 including before the first column. Actual spacing rules are explainable but messy. n WRAP with NAMED options create messy output. n If all variables are numeric and none are specified as DISPLAY, they are summed instead of listed. n MISSING option is needed to print all data rows. n If a variable name not in the data set, is listed in both the COLUMN and DEFINE statements, no error will result.
PROC REPORT Justification Rules n Default is right for numeric - left for character. n Numerical values are right justified within formats which are justified within the width. n Character values are justified in width with leading blanks retained and trailing blanks eliminated. n Rules apply simultaneously to labels and values.
PROC REPORT SPLIT Character n The SPLIT character splits both labels and FLOW variables. n Choose a printable character(e.g., “~”, “|”, “\”) other than the default “/” which is common in many entered texts. n If a word’s length in a flowed variable is greater than the variable’s width, the word will split at that width. n To indent flowed text, insert a split character plus the desired number of spaces and one at the end of the text. n If there is a split character in the flowed variable, words at the end of the field will split randomly due to a SAS bug which will be fixed in a future SAS version. To fix this one either widens the field to eliminate non-indented flow or writes a macro to insert split characters where desired. n If unprintable printer control characters exist in the flowed variable, they must be removed. This is an uncommon problem which can happen if data is coming from many sources.
Solution 3: Use ID Statement (introduced in 6.12) With PROC REPORT n Observations are identified. n However, All Other Default Problems Exist. n Won’t Work if the Width of any Variable ¬ Exceeds the Inherent PROC REPORT limit. Plus the Width of the ID variables Plus the Spaces Between Columns Exceeds Line Size. (In this case the FLOW option must be used.)
Solution 4: PROC REPORT with Minimal Options for a Narrow Data Set n Must Use a COLUMN Statement (Analogous to a VAR statement in PROC PRINT). n Use a BREAK Statement for spaces between lines. n Use HEADLINE, HEADSKIP, BREAK Statement or underline to separate labels from the observations. n Specify a Constant Spacing Between Columns. n Customize Labels in the DEFINE statements or Use Variable Names (System NOLABEL option). n Possibly use PANEL option to minimize paper use. n The above gives you most of the features of using a PUT statement formatting (DATA _NULL_).
If the width of a data set won’t fit within the line size, one should make the output compact. In a compact output, the maximum number of observations of the variables should be made to either fit on the width of a single page or on the width of a minimum number of pages. Author’s Opinion: Presenting the data in columns on a single page width, neatly and informatively, is more heuristic than presenting it on multiple pages. Solution 5: Use PROC REPORT With All Applicable Options for a Wide Data Set
To make the report compact n Make every reasonable effort to limit width to a single page. n Reduce the space between columns to one. n Drop space before 1 st column (SPACING=0 in DEFINE). n Drop unnecessary variables from COLUMN statement. n Drop variables having the same value for all observations and consider putting them in a title, footnote or legend. n Sort the data by sensible variables having a fair number of rows for each combination in the BY statement and use the BY in PROC REPORT. n For data sets wider than a single page, pick the minimum # of ID variables to adequately identify all observations. Balance the width of the non-ID variables across pages. n Use PROC FREQ to determine whether long variables can be coded and describe the code in a legend.
To make the report compact n Don’t use the FLOW option unless necessary as it increases the number of lines per observation. Also, consider not using the SPLIT character in its label. n Don’t alter any variable if proofreading. n Eliminate variables which have a one to one relationship with other variables. n Sensibly condense character variables. n Edit variables without eliminating their meaning. n Transfer meaning from a variable to its label. n Since formats can alter variable widths, apply them prior to calculating column widths. n Use the STYLE attribute, some of the 6 font parameters and ODS. While good for publications, this doesn’t support a standardized line size and appearance.
For alphanumeric variables n Determine their maximum width in the data set. n If a format increases this width, use that width. n Consider removing any invariant prefixes or suffixes n If the FLOW parameter is required, consider the line size constraint, calculate the width plus spacing of all other variables and: ¬For a single FLOW variable, use its maximum width. For multiple FLOW variables, determine how to best allocate their widths to minimize lines per observation. ® See if other data can be put on the added line(s) per observation (e.g., concatenate visit date, SPLIT character and visit name and use the FLOW option).
For numeric variables n Determine their range, maximum value and whether they’re integer and then specify an appropriate format (not the default BEST) and decimal point. n For date time variables, specify an appropriate compact format (e.g., MMDDYY6.). Separate date and time with DATEPART. If time is missing for all observations remove it from the report. n If it has a format which transforms it into an alphanumeric variable, apply the format and treat it as though it were an alphanumeric variable.
To increase the attractiveness of a compact report n Appropriately order the COLUMN statement variables. n Appropriately specify ORDER variables and the BREAK statement (e.g., blank line between ID variables). n Use informative labels neatly spanned in the COLUMN statement and appropriately split in the DEFINE. n Use tricks (e.g., unprintable character at end of label, SPLIT character and blank at beginning of label, spacing =0) to separately justify labels and values. n Use neat and informative titles, footnotes and/or legends. If necessary, expand a label’s meaning in a legend.
20 Possible Variables for Compact Output
Condensing and Editing LVALC and SASNAME
Compact Output (15 Variable) Data Step
Final Compact Output
Compact Output PROC REPORT
Compact Output With BY Statement
Compact Output With Patient ID Option
General ECGTEST Compact Report n Decide what variables to always exclude. n Decide constant variables for title. n Decide what 1 to 1 variables to include. n Count and remove applicable leading zeroes. n Determine which data condensing tricks work. n If not condensable, they must be output in full n Predetermine variables that need FLOW. n Determine which variables have a fixed width. n Calculate width of all remaining variables. n Use BY variables and the ID option for date.
Compact Output With Visit ID Option
Original AE PROC REPORT Code
Changes Made to Produce Final Listing n Width of all variables was minimized. n Leading zeroes were stripped from subject; it was concatenated with age sex and FLOW added. n Century was eliminated and date was output after subject and made an ORDER variable. n Body system was coded into footnotes. n Verbatim label indentation was corrected. n Labels were beautified. “STUDY DAY” was centered. n Width of indented column was maximized to eliminate FLOW of the concatenated variables. n DAI was put in data set and FLOW added. The above reduced the output from 21 to 11 pages.
Final AE PROC REPORT Code
Creating an Automated AE Listing l Find variables needed for other projects and: ¬ Find if their width is variable and calculate it. Make attractive labels with SPLIT characters. ® Exclude them if they are blank (e.g., time). ¯ Use minimum possible width. ° 2 lines per observation: Thus use FLOW? l Maximize width of the verbatim variable. l User should specify variables and their order. l Change footnotes to an automated legend. l Add options for the BY variables.