e-Guide |
Gallery |
Mind Map |
Getting Started |
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 Clinical Data Reporting. For formatting syntax, see ODS Style example. See e-Guide. See Anatomy of Proc Report.
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 |
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: ods rtf file = "&path\&dirname\demog_rpt4.rtf" bodytitle; footnote3 j=l "Table run: &dtm"; (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 List, Help with Character Map
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;
SAS Course Notes Practically Perfect Presentations Using ODS and PROC REPORT, Cynthia Zender
SAS Course Notes A Tutorial on Proc Report, Cynthia Zender
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 HOW PROC REPORT Basics: Getting Started with the Primary Statements, Art Carpenter
Animated Guide PROC REPORT, Russ Lavery
Book Chapter The REPORT Procedure
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]
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
6. PROC REPORT- A BETTER WAY TO DISPLAY DATA, David Lafontant [Presentation]
Advanced SAS Programmer |
SAS® HOW Presentation Practically Perfect Presentations [ODS, See Gallery for Proc Report and ODS Syntax Options]
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
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]
12. TIPS AND TRICKS FOR CREATING THE REPORTS YOUR CLIENTS NEED TO SEE, Michael Molter
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)
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
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
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
41. Reporting Statistical Results with PROC REPORT, Nestor Rohowsky
42. Generating Customized Analytical Reports from SAS Procedure Output, Brinda Bhaskar, Kennan Murray [Model, Best Practice with ODS Template, SPARSE, OUTPCT]
43. Using PROC REPORT and ODS STYLE Options to Make Really Great Tables, Wendi Wright
44. PROC REPORT: Titling It Right, with Footnotes to Boot, William Murphy
45. One Macro Does It All – Advanced Enhancement of PROC REPORT, Peng-fang Yen
46. Using Formats and Other Techniques to Complete PROC REPORT Tables, David Chapman
47. Maintaining ORDER in Your (PROC) Reporting, Bill Coar
48. PROC REPORT: Tips and Customizations for Quickly Creating Customized Reports, Jonathan Duggins
49. Sailing Over the ACROSS Hurdle in PROC REPORT, Cynthia Zender
50. Beyond the Basics: Advanced REPORT Procedure Tips and Tricks Updated for SAS® 9.2, Allison Booth
51. Beyond the Basics: Advanced PROC REPORT Tips and Tricks, Allison McMahill