Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.

Slides:



Advertisements
Similar presentations
Haas MFE SAS Workshop Lecture 3:
Advertisements

TUTORIAL 1 Getting Started with Excel
DIVERSE REPORT GENERATION By Chris Speck PAREXEL International Durham, NC.
Understanding Microsoft Excel
Creating a Compact Columnar Output with PROC REPORT Walter R. Young Principal Clinical Programmer Analyst Wyeth.
Page Features Footnotes and endnotes Headers and footers Page numbering Margins Columns.
CREATING A MULTIPLE PAGE REPORT Presented by: Dr. Ennis-Cole.
SAS coding used in creating a routine report February 23, 2009 February is Heart Month.
1 ADVANCED MICROSOFT POWERPOINT Lesson 5 – Using Advanced Text Features Microsoft Office 2003: Advanced.
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Word 2003 Lab 3 Creating Reports and Tables.
Chapter 10 Formatting a Document.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Let SAS Do the Coding for You! Robert Williams Business Info Analyst Sr. WellPoint Inc.
Data Cleaning 101 Ron Cody, Ed.D Robert Wood Johnson Medical School Piscataway, NJ.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
CTS130 Spreadsheet Lesson 7 Using Logical and Financial Functions.
Copyright © 2010, Meta-Xceed, Inc. All rights reserved. BI Flash and all other Meta-Xceed Inc. product or service names are registered trademarks or trademarks.
Developing Effective Reports
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
SAS PROC REPORT PROC TABULATE
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Different Decimal Places For Different Laboratory Tests PharmaSug 2004, TT01 A. Cecilia Mauldin.
HPR Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected by copyright law and.
1 Data List Spreadsheets or simple databases - a different use of Spreadsheets Bent Thomsen.
Essential ODS PDF Patrick Thornton.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
WORKBOOK FORMATTING Nolan Tomboulian Tomboulian.wikispaces.com HOW THINGS LOOK CELL COLORFONT COLOR CELL BORDERSFONT SIZE CELL SIZEFONT.
Word 2013 Certification Skills Measured. 1. Create and Manage Documents  Create a Document  Navigate through a Document  Format a Document  Customize.
1 Efficient SAS Coding with Proc SQL When Proc SQL is Easier than Traditional SAS Approaches Mike Atkinson, May 4, 2005.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
Introduction to Enterprise Guide Jennifer Schmidt Rhonda Ellis Cassandra Hall.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Priya Ramaswami Janssen R&D US. Advantages of PROC REPORT -Very powerful -Perform lists, subsets, statistics, computations, formatting within one procedure.
Lesson 1 – Microsoft Excel * The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
1 Lesson 13 Organizing and Enhancing Worksheets Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
Tips & Tricks From your fellow SAS users 9/30/2004.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
Typing and Formatting a Research Paper WORD 2013.
Chapter 14 Formatting Readable Output. Chapter Objectives  Add a column heading with a line break to a report  Format the appearance of numeric data.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
The Basics of Microsoft Word Getting Started and Formatting your paper.
Managing Text Flow Lesson 5. Setting Page Layout The layout of a page helps communicate your message. Although the content of your document is obviously.
Key Applications Module Lesson 14 — Working with Tables Computer Literacy BASICS.
Lecture 3- Microsoft Word COE 201- Computer Proficiency.
Computing with SAS Software A SAS program consists of SAS statements. 1. The DATA step consists of SAS statements that define your data and create a SAS.
Chapter 6 Concatenating SAS Data Sets and Creating Summary Reports Xiaogang Su Department of Statistics University of Central Florida.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
 The formatting applied to a document can affect: › How the reader interprets the document › How easily the document is read › The overall impression.
Patrick Thornton SRI International.  Example of a Multiple Response Item ◦ Variable coding and example data  A Cross Tabulation using Proc REPORT 
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
MANAGING TEXT FLOW Lesson 5. OBJECTIVES SOFTWARE ORIENTATION The Page Layout tab contains groups of commands that will produce a formatted document’s.
Hints and Tips SAUSAG Q SORTING – NOUNIQUEKEY The NOUNIQUEKEY option on PROC SORT is a useful way in 9.3 to easily retain only those records with.
A MORE COMPLETE ODS REPORT. What we’re going to talk about…  Creating a title page  Creating an introduction page  Creating long-form text descriptions.
Loops BIS1523 – Lecture 10.
Chapter Twenty Producing Readable Output
Understanding Microsoft Excel
Defining and Calling a Macro
Bring the Vampire out of the Shadows: Understanding the RETAIN and COUNT functions in SAS® Steve Black.
Lab 3 and HRP259 Lab and Combining (with SQL)
Understanding Microsoft Excel
Microsoft Official Academic Course, Microsoft Word 2013
Tips and Tricks for Using Macros to Automate SAS Reporting.
Key Applications Module Lesson 14 — Working with Tables
Presentation transcript:

Outline Proc Report Tricks Kelley Weston

Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level detail in the titles 3.Titles and footnotes at different placesTitles and footnotes at different places 4.Adding a space when adding a space doesn't workAdding a space when adding a space doesn't work 5.Using a character that needs to sort before a spaceUsing a character that needs to sort before a space 6.Using a better underlineUsing a better underline 7.Stacking multiple variables in one columnStacking multiple variables in one column 8.Avoid orphaning groups of rows in listingsAvoid orphaning groups of rows in listings Ex 1Ex 2Ex 3Ex 4Ex 5Ex 6Ex 7Ex 8

Outline 1.Text that spans columns Desired Output: Patient Date 1 01NOV2005 Test 1: this is my sample long text Test 2: this is my sample long text 2 02NOV2005 Test 1: this is my sample long text Test 2: this is my sample long text

Outline Notice that: Some information is in columns, under column headings (patient number and date) Some information is on multiple lines that spans columns (test 1 and test 2)

Outline Sample code: Create dataset: data work.temp; input pt : $1. date : mytext $char50.; cards; 1 01nov2005 this is my sample long text 2 02nov2005 this is my sample long text run;

Outline Report code: Part 1: proc report data = work.temp nowd ; %* variable to be used in compute block must come before break variable; column mytext pt date; define pt / order "Patient" width = 7 center ; define date / order "Date" width = 9 format = date9. left ;

Outline Report Code Part 2: *the variable to be used in the compute block must be defined as an order variable and use the noprint option; define mytext / order noprint; compute after pt; %* 1st method of printing line; "Test 1: mytext $50.; line " "; %* 2nd method of printing line; length text $75; text = "Test 2: " !! mytext; text $75.; line " "; endcomp; break after pt / skip; run;

Outline 2.Patient-level detail in the titles Desired Sample Output: ____________ Sample report <- title 1 line Patient: 1 Y = A <- title2 line _________ Z <- column heading _________ 9 <- variable value _____________ Sample report Patient: 2 Y = B ____________ _________ Z _________ 8 Outline

Outline: 1.Put patient information in macro variables 2.Create proc report with titles containing macro variables 3.Wrap proc report within a macro loop to process all patients

Outline Create dataset: data work.temp; input patient y $ z; cards; 1 A 9 2 B 8 run;

Outline Step 1 - Put patient information into macro variables proc sql noprint; select count(patient) into :cnt_x from work.temp; %let cnt_x = &cnt_x; select distinct patient, y into :x1 - :x&cnt_x /* patient number */, :y1 - :y&cnt_x /* other var. to be in ttl */ from work.temp; quit;

Outline Step 2 - Create proc report with titles containing macro variables title1 "________________________________________"; title2 "Sample report"; title3 "Patient: &&x&cnt Y = &&y&cnt"; title4 "________________________________________"; proc report data = work.temp nowd headline; column ("__" z); define z / "Z"; where Patient = &&x&cnt; run;

Outline Step 3 - Wrap proc report within a macro loop to process all patients %macro test; %local cnt; %do cnt = 1 %to &cnt_x; title1 "________________________________________"; title2 "Sample report"; title3 "Patient: &&x&cnt Y = &&y&cnt"; title4 "________________________________________"; proc report data = work.temp nowd headline; column ("__" z); define z / "Z"; where Patient = &&x&cnt; run; %end; %mend test; %test;

Outline 3.Titles and footnotes at different places Outline

Titles within proc report: proc report data = work.report column x; Define x / display; compute before ; line "Title at the beginning of the report"; line " "; endcomp; %* between Titles & column headers; compute before _page_ / center; line "Title at the beginning of each page"; line " "; endcomp; run;

Outline Footnotes within proc report: proc report data = work.report column x; Define x / display; %* before footnotes specified in Footnote stmts; compute after _page_ / center; line " "; line "Footnote at the end of each page"; endcomp; compute after; line " "; line "Footnote at the end of the report"; endcomp; run;

Outline 4.Adding a space when adding a space doesn't work If Proc Report does not maintain the space you need (for example, in a label), then you can use ASCII 160 / hex A0) – used in column titles to indent (Proc Report won't keep space [ASCII 32]) Define x / " Column* Title" left; Could still be printed as: Column Title When you really want: bbColumn bbbbTitle

Outline Two ways of achieving this: If using UltraEdit, use the ASCII table: View / ASCII table / click on Dec 160 / hex A0 / Click on Insert char

Outline If you are not using UltraEdit, then use the numeric keypad: Alt – (hold down the Alt key for the entire number.)

Outline 5.Using a character that needs to sort before a space If you have something in your report dataset that needs to sort before something that contains a space, insert a null character (ASCII 00 / hex 00) You can insert it into your data in the same way as inserting the "new" blank (ASCII 160). For instance, when creating Adverse Event tables, and indenting the PT (Preferred term) underneath the SOC (System Organ Class), and trying to get everything to sort properly, you can precede the SOC with an ASCII 00, which will sort before the space (ASCII 32 / hex 20)

Outline 6.Using a better underline (use "~~" in column statement, then use customized SAS macro)

Outline Step 1: Run Proc Report to create *.lst file Step 2: Run macro that will replace "~" with graphics character

Outline Step 1: Run Proc Report: proc report formchar(2) = "~"; /* by default this is a dash */ columns ("~~" vars1 - vars3 ); /* a dash is commonly used here */

Outline Step 2: Run macro to replace "~" with graphics dash: The macro contains the following code: if index(text, '~') > 0 then text = tranwrd(text, '~', '97'x); This replaces the tilde (~) with a graphics hyphen (—) in the list file. Normally, a regular hyphen (-) will be used, which will show space between the hyphens. This assumes that the tilde will not be used anywhere else in the report.

Outline 7.Stacking multiple variables in one column The split character defined in the Proc Report statement will work not only in the label, but in the data as well: col1 = trim(left(var1)) !! "#" !! trim(left(var2)); proc report split = "#" ;

Outline 8.Avoid orphaning groups of rows in listings Adapted from "Controlling Page Breaks when using Proc Report", paper by Cynthia Stetz, Merrill Lynch There are times when you may want to keep all of group of items on a single page, instead of starting the group in the middle of one page, and continuing the group on the next page. Instead of trying to account for it yourself, let SAS do it.

Outline Step 1: Define number of observations in every group - used for page breaks in report Step 2: Increment the page counter Step 3: Proc Report Code

Outline Step 1: Define # of obs in every group - used for page breaks in report proc sql noprint; create table work.report as select *, count(visit) as rec_cnt from work.report group by site order by site, visit; quit; Notes: Site is the group-by, order-by, first. variable in this example. This is a variable that has the same value on many observations. Visit is the variable that is being counted. It has a different value on every observation. It is not a group-by variable.

Outline Sample Output Obs site VISIT rec_cnt < | 6 obs | in | first | group < < | 7 obs | in | second | group | <- +

Outline Step 2: Increment Page Counter data work.report (drop = max lns_on_pg); set work.report; by site; retain lns_on_pg 0 max 48 /* less than page size value */ pg_ejct 1 /* break var. in proc report */; if first.site then do; %* +2 is to compensate for break lines; lns_on_pg = lns_on_pg + rec_cnt + 2; if lns_on_pg GT max then do; pg_ejct + 1; lns_on_pg = rec_cnt + 2; end; %* lns_on_pg GT max; end; %* first.site; run;

Outline Sample Output: After defining page eject (only 1 st obs of each group shown) Obs site VISIT rec_cnt pg_ejct <- + all obs... | for these | sites | on | page one < page 2 starts

Outline Step 3: Proc Report Code: proc report; columns ("__" pg_ejct var1 -- var5); define pg_ejct / order noprint; break after pg_ejct / page; run;

Outline Thank you ! Kelley Weston Quintiles