PROC REPORT    

 e-Guide

 Gallery

 Mind Map

 Getting Started, SAS Audio Blog


Smarter PROC REPORT searches - The best SAS® Procedure for producing publication quality summary tables or listings.  Visit the PROC REPORT Gallery to select SAS® example from one of the table layouts,  access the PROC REPORT e-Guide for a complete list of table layouts, or access the Technical Report for complete list of examples by tasks.  See DATA Step and Merge for post RTF file processing example, ODS and Pharmaceutical examples blog.  For formatting syntax, see  ODS Style example. See e-Guide.

 

Proc Report Map


 

           B1.4 One or more Table Sections
STYLE(X1 X2)

(Best to always specify)


PROC REPORT Statement
(DEFINE/BREAK/RBREAK/ COMPUTE BLOCK 
 overrides PROC REPORT level)

C2. Override
Default Style Element with one or more
Style Attribute and Value 
STYLE(TABLE_SECTION(S)) =             [ATTRIBUTE1 = VALUE1 
ATTRIBUTE2 = VALUE2]
 
 REPORT (Default)

 PROC REPORT   TABLE (Default Style Element)
 COLUMN 

 PROC REPORT, DEFINE
 DATA (Default Style Element)
 HEADER (Default for DEFINE)

 PROC REPORT, DEFINE
 HEADER (Default Style Element)
 SUMMARY

 PROC REPORT, BREAK/RBREAK
 DATAEMPHASIS (Default Style Element)
 LINES  PROC REPORT, BREAK/RBREAK, COMPUTE BLOCK
 NOTECONTENT (Default Style Element)
 CALLDEF  PROC REPORT, CALL DEFINE within COMPUTE BLOCK
 DATA (Default Style Element)


 
B1.4 Examples
Insert Style In -
SAS Paper, In-Line Fomatting


Affects this Table Section
 

proc report data=sashelp.prdsale nowd style(summary) = {background=green}; 


All Summary rows 

proc report data=sashelp.prdsale nowd style(column) = {background=green};

All Columns (Not recommended)
 
 define actual / style(column) = {background=green}); 

ACTUAL column 
 
 compute actual;
  call define(actual, 'style', 'style =      {background=green}');
endcomp;

Computed ACTUAL column 

B1.4 Useful Proc Report Style Attributes

 Statement

Section  Attribute Value 
 PROC REPORT

STYLE(REPORT)=  {CELLSPACING=3 BORDERWIDTH=5 JUST=CENTER ASIS=ON RULES=GROUPS}; 
 PROC REPORT

STYLE(HEADER)=  {VJUST=MIDDLE}; 
 DEFINE N

STYLE(COLUMN)=  {FONT_WEIGHT=BOLD CELLWIDTH=3CM FONT_FACE=HELVETICA JUST=CENTER INDENT=10PT}; 
 DEFINE RACE

STYLE(COLUMN)= {FONT_FACE=ITALICS 'Race'};
 DEFINE RACE

   /'^R" \i\fs24 " Race';     (alternative to STYLE(COLUMN))

 

Without BREAK statement


With BREAK statement, _BREAK_ 

(N/A for RTF)

Continuous rows across pages

Create page variable to count rows with manual determination of page breaks

 





Header/Footer Section contains Global Titles/Footnotes


BODYTITLE option produces Titles/Footnotes within the Table 

Alternative to BODYTITLE and ^{PAGEOF} issues:

1 - Add BODYTITLE_AUX option

2 - Insert Microsoft Word syntax for Page X of Y.  This technique keeps titles and footnotes with the table as well as correctly display the Page X of Y in the footnote.

ods rtf file = "&path\&dirname\demog_rpt4.rtf" bodytitle;

footnote3 j=l "Table run: &dtm";
j=r "{Page} {\field{\*\fldinst { PAGE }}}\~{of}\~{\field {\*\fldinst
{ NUMPAGES }}}"
;

(Note that BODYTITLE issue such as with PAGEOF may be resolved with more recent SAS versions - See ODS.)

BREAK statement controls the display of Titles/Footnotes or blank rows by variable for per page breaks

 N/A

SUMMARIZE, STYLE, PAGE, SUPPRESS

Listing only: DOL, OL, DUL, UL, SKIP 

 

***code for generating page numbers in proc report;

PROC SQL NOPRINT;

SELECT max(page) into :tpg FROM rpt ;

SELECT length(compress(put(max(page),best.))) into :tpgd FROM rpt ;

QUIT; %put &tpgd;

data _null_;

 call symput("_tpg",compress(put(&tpg,&tpgd..)));

run; %put ****&_tpg.***;

*--------------------------------------------------------------;

options missing='';* ls=120 ps=65 nodate nonumber orientation = Landscape;

%macro rpt;

ods escapechar '^';

proc report data=rpt nowindows headskip headline missing split = '~' spacing=1 style(column)={asis=on} style={pretext="\b &tblnum &_t_1 \line &_t_2 \line"};

by page pg;

column page pg ord1 

(label1 col1 (" ^R/RTF'\brdrb\brdrs Phase 2" col2 col3 col4 ) ) ;

define page / order order = internal noprint ;

define pg / order order = internal noprint ;

define ord1 / order order = internal noprint ;

define label1 /display style(column)={just=left cellwidth= 4in} style(header)={just=left} "" width = 40 flow;

define col1 / display style(column)={just=center cellwidth=1.25in} "Phase 1~(N = &n1)" flow ;

define col2 / display style(column)={just=center cellwidth=1.25in} "Cohort 1~(N = &n2_1)" flow ;

define col3 / display style(column)={just=center cellwidth=1.25in} "Cohort 2~(N = &n2_2)" flow ;

define col4 / display style(column)={just=center cellwidth=1.25in} "Total~(N = &n3)" flow ;

compute before ord1; line @1 ""; endcomp;

compute before page; comppage=page; endcomp;

compute after _page_/center;

line "^R/RTF'\qr\ Page " comppage &tpgd.. " of &_tpg."

"\par\sbys\ql &_f_1" ;

line "&_f_2 "; line "&_f_3"; line "&_f_4"; line "&_f_5"; line "&_f_6";

line "^R/RTF'\par\sbys\ql PROGRAM NAME: &pgm"

" DATE: &systime/&sysdate9";

endcomp; run; 

PROC SORT DATA; BY AGE SEX; RUN;

PROC REPORT; COLUMN       AGE         SEX;
       <outer Group> <Inner Group>

BREAK AFTER AGE / PAGE;
BREAK AFTER SEX / PAGE; RUN;

Output -
Age Name Sex
12  Barb  F  <- break after sex
12  Carl  M
12  Dave  M  <- break after sex same as age

13  Edna  F
13  Fran  F  <- break after sex
13  Gene  M
13  Harry M
13  Ivan  M  <- break after sex same as age

14  Jill  F
14  Kathy F
14  Laura F  <-break after sex same as age

SAS Paper, Unicode List, Hex to Decimal ListHelp with Character Map

Special_Char.txt

______________________________________________

 TABLE BODY

COMPUTE_COLUMN_VARIABLE 

 COMPUTE_ROW_VARIABLE

Summary Stats (.MIN, .MAX, .SUM, .MEAN)

Basic Syntax of PROC REPORT statements:
 COLUMNS <VAR1> <VAR2>;

 DEFINE <VAR1> / <OPTIONS>;
 DEFINE <VAR2> / <OPTIONS>;

 COMPUTE;
 ENDCOMP;

 BREAK;
 RBREAK;
RUN;

Proc Report Gallery

SAS® Guide book PROC REPORT Examples

SAS Course Notes Practically Perfect Presentations Using ODS and PROC REPORT, Cynthia Zender

SAS Course Notes A Tutorial on Proc Report, Cynthia Zender

Presentation Tips and Tricks, Mike Molter  [Paper]

RTF Control Words Reference

See Top Pharmaceutical Industry Papers section for more Proc Report examples

______________________________________________

Default Proc Report Listing

LAB_TEST  VISIT_DT Columns 1 to 50   VISIT_DT Columns 51 to 100
 Records 1 to 50

1

 3 

 Records 51 to 100

2

4

Order for records and columns spanning across multiple pages using either ACROSS variable for dynamic columns or fixed column variables.  For ACROSS variable, columns 1 to 50 for all records 1 to 50 and then 51 to 100 are displayed before columns 51 to 100 for all records 1 to 50 and then 51 to 100.  Columns 1 to 50 and 51 to 100 represent unique values of VISIT_DT variable.  All LAB_TEST values are displayed first before displaying the next set of VISIT_DT values.  Table headers may repeat if number of records is less that the page length number of records. 

Options to control Proc Report Listing

LAB_TEST  VISIT_DT Columns 1 to 50   VISIT_DT Columns 51 to 100
 Records 1 to 50

1

 2

 Records 51 to 100

3

4

Order and page breaks - sort by key variables, group blocks of records with counters, fill blank records to end of page, and subset Proc Report for each page basically.  This techniqe not only prevents dupluicate table headers on pages, but also displays all VISIT_DT for a set of LAB_TEST before displaying the next set of LAB_TEST values.  Note that you may need to test and adjust your code to perfect this method and that this technique will work with as a SAS Listing but not with ODS. 

______________________________________________

 Beginner SAS Programmer


In general, when learning PROC REPORT, these are the first set of typical tables to create. 

 1) Listing or display of selected or all variables

 2) Listing or display of selected or all variables with formats and labels

 3) Order and group by key variables to display listing

 4) Analysis define type on numeric variable to create summary tables

 5) Creating multiple statistics on the same numeric variable in summary table

 6) Across or nesting of numeric variable for summary table

 7) Adding breaks by group key variables or grand totals

 8) Adding temporary variables that reference table column numbers with the compute block

Beginner Paper A Step-by-Step Introduction to PROC REPORT, David Lewandowski

Beginner Paper Learning PROC REPORT by Comparison, Keith Cranford

Beginner Presentation Proc Report

Beginner HOW PROC REPORT Basics: Getting Started with the Primary Statements, Art Carpenter

Animated Guide PROC REPORT, Russ Lavery

How - Build a Summary Table Using Proc Report and ODS “Table 1” in Scientific Manuscripts; Using PROC REPORT and the ODS System, Carter Sevick [Model, See Gallery for model_proc_report.sas]

SAS® Reference The REPORT Procedure: Getting Started with the Basics

SAS® Reference PROC REPORT SyntaxPROC REPORT StatsTechnical Report

1. Getting Up to Speed with PROC REPORT, Kimberly LeBouton

2. Fast Track to PROC REPORT Results, J. Meimei Ma, Sandra Schlotzhauer

3. Quick Results in PROC REPORT, J. Meimei Ma, Sandra Schlotzhauer, Maria Ilieva

4. A Gentle Introduction to the Powerful REPORT Procedure, Ben Cochran

5. PROC REPORT: How To Get Started, Malachy Foley


 Advanced SAS Programmer


SAS® HOW Presentation Practically Perfect Presentations [ODS, See Gallery for Proc Report and ODS Syntax Options]

SAS® Presentation Compute Blocks Revealed, Sandy McNeill

SAS® Tip 1 Calculate Percents under ACROSS Variable

1. Format Challenges with PROC REPORT, Lisa M. Schneider

2. Advanced PROC REPORT: Getting Your Tables Connected Using Links - Part I Tutorial,
Art Carpenter

3. Advanced PROC REPORT: Getting Your Tables Connected Using Links - Part II Practicum,
Art Carpenter

4. PROC REPORT: Compute Block Basics – Part I Tutorial, Art Carpenter

5. PROC REPORT: Compute Block Basics – Part II Practicum, Art Carpenter

6. Advanced PROC REPORT: Traffic Lighting - Controlling Cell Attributes With Your Data, Art Carpenter

7. ADVANCED FEATURES OF PROC REPORT WORKSHOP, Kim L. Kolbe Ritzow

8. Evolve from a Carpenter’s Apprentice to a Master Woodworker: Creating a Plan for Your Reports and Avoiding Common Pitfalls in REPORT Procedure Coding Allison McMahill Booth 

9. Color, Rank, Count, Name; Controlling it all in PROC REPORT, Arthur Carpenter

10. Creating a Compact Columnar Output with PROC REPORT, Walter Young [Adverse TOX Grades]

11. Enhancing RTF Output with RTF Control Words and In-Line Formatting, Lori S. Parsons [RTF Control Words]


 Macro SAS Programmer


SAS® Tip SAS SAS Macro to break up text

1. Beyond the Basics: Advanced REPORT Procedure Tips and Tricks Updated for SAS® 9.2,
Allison Booth
 (TAGSETS.RTF)

2. Thirty Three Tricks with PROC REPORT: A Quick Introduction to the Powerful REPORT Procedure, Ben Cochran

3. Custom Template for Reporting Interim Analyses Using PROC REPORT and Output Delivery System (ODS), Hanaa Girgis


11. PROC REPORT: Doin’ It in Style!, Ray Pass, Sandy McNeill

12. So Now You’re Using PROC REPORT–Is It Pretty and Automated?, Daphne Ewing, Ray Pass

13. A Technique for Producing Sorted Columns with a Hanging First Line Using PROC REPORT
David Izard, David Chen

14. Using PROC REPORT to Generate Impossible Totals, Andrea Decker

16. Creating Word Tables using PROC REPORT and ODS RTF, Carey Smoak [BODYTITLE]

17. Perfecting Report Output to RTF, Steven Feder [PROC REPORT, PROC TEMPLATE]

18. ODS RTF: Practical Tips, Cindy Tong

19. To ODS RTF and Beyond, David Shannon

21. PROC REPORT COMPUTE Block and Conditional Footnote, Yumi Sembongi

22. PROC REPORT Unwrapped: Exploring the Secrets behind One of the Most Popular Procedures in Base SAS® Software, Allison McMahill Booth

23. Now There Is an Easy Way to Get to Word, Just Use PROC TEMPLATE, PROC REPORT, and ODS RTF, Bob Hull

24. Data Dependent Footnotes using PROC REPORT, Angelina Cecilia Casas

25. Page X of Y with Proc Report, Chang Y. Chung, Toby Dunn

28. PROC REPORT and ODS, Cindy Stroupe

29. Pretty Please?! Making RTF Output “Pretty” with SAS, Carol Matthews, Elena Kalchenko

30. “ACROSS” in PROC REPORT, Jiang Jin

31. Producing Special Characters in SAS Output in RTF, Cindy Song

32. Using PROC REPORT To Produce Tables With Cumulative Totals and Row Differences, David  Chapman [Percentages]

33. Getting Freqy with PROC REPORT, Ethan Miller [Percentages]

34. ORDER, ORDER PLEASE: SORTING DATA USING PROC REPORT, Lisa Fine

35. Proc Tabulate: Extending This Powerful Tool Beyond Its Limitations Justin Jia, Amanda Lin [_c1_]

36. The REPORT Procedure: A Primer for the Compute Block, Jane Eslinger

37. A Macro to Indent and Hyphenate Lengthy Text in PROC REPORT, Stanley Yuen

38. Customize comparison tables for clinical studies, Polina Kukhareva, Kathy Roggenkamp [Baseline characteristics]

39. Using PROC REPORT to Describe Case and Control Comparisons, Sara Yuewen Gao

40. The REPORT Procedure and ODS Destination for Microsoft Excel: The Smarter, Faster Way to Create First-Rate Excel Reports, Jane Eslinger

41. Reporting Statistical Results with PROC REPORT, Nestor Rohowsky


Search for SAS papers by Allison Booth

SAS® Savvy Class: Publication Quality Tables using Proc Report (New) 

Powered by Wild Apricot Membership Software