Presentation is loading. Please wait.

Presentation is loading. Please wait.

Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth.

Similar presentations

Presentation on theme: "Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth."— Presentation transcript:

1 Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth

2 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.

3 PROC CONTENTS for ECGTEST 57 Variables 28 Observations

4 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.

5 Default PROC PRINT


7 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.

8 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.

9 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.

10 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.

11 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.)

12 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_).

13 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

14 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.

15 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.

16 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).

17 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.

18 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.

19 20 Possible Variables for Compact Output

20 Condensing and Editing LVALC and SASNAME

21 Compact Output (15 Variable) Data Step

22 Compact Output

23 Final Compact Output

24 Compact Output PROC REPORT

25 Compact Output With BY Statement

26 Compact Output With Patient ID Option


28 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.

29 Compact Output With Visit ID Option


31 Original AE PROC REPORT Code





36 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.



39 Final AE PROC REPORT Code

40 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.

Download ppt "Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth."

Similar presentations

Ads by Google