PROC REPORT In SAS (With 15+ Examples)

PROC REPORT statement combines features of the PROC PRINT, PROC MEANS , and PROC TABULATE procedures with features of the DATA step in a single report-writing tool that can produce a variety of reports.

You can use PROC REPORT procedure to create a report with the SAS dataset and in the formats you would like to see in the report.

What Does The PROC REPORT Procedure Do?

  • Tabular Reporting : PROC REPORT enables you to create tabular reports that organise data in the rows and columns.
  • Grouping and Breaks : You can group data based on one or more variables and create break lines that visually separate the groups. This helps in organizing and summarizing data by different categories.
  • Summary Statistics : You can calculate summary statistics such as sums, means, counts, minimums, maximums, and more for specific variables or groups using PROC REPORT.
  • Calculated Columns : PROC REPORT allows you to create new columns in the report that are calculated based on expressions or computations involving existing variables.
  • Conditional Formatting : PROC REPORT supports conditional formatting, allowing you to highlight specific cells, rows, or columns based on certain conditions.
  • Customization and Formatting : PROC REPORT provides a wide range of options for customizing the appearance and layout of your report. You can control fonts, colours, borders, spacing, alignment, and other formatting aspects to create visually appealing reports.

Basic syntax:

Explanation:

  • DATA= Specify the input data set to be used for processing. 
  • HEADLINE Create a horizontal line between the column headers and the body of the report. 
  • HEADSKIP Create a blank line between the column headers and the body of the report. 
  • NOWINDOWS Suppress the REPORT window and direct the report output to open ODS destinations. 
  • OUT= Create an output SAS data set.
  • OUTREPT= Specify a location to store the report. 
  • PROMPT Activate prompting mode by using a built-in wizard.
  • REPORT= Specify a stored report to be used in generating a new report.

A Simple PROC REPORT Example

You can simply use the proc report procedure without defining anything or adding any features or options to print the dataset in the output. It works exactly similar to the proc print procedure.

The following sample dataset will be used to demonstrate the different use cases and examples of using PROC REPORT in SAS.

The PROC REPORT procedure without any other statement just prints the dataset. The below code produces the same results as if you execute the PROC PRINT procedure.

Proc report in sas sample dataset

PROC REPORT With Column Selection

By default the proc report procedure considers all the columns and prints it in the output report. But you can also choose variables that appear in the output report by using a COLUMN statement followed by a list of variables that needs to be added in the report.

This example selects only four variables: region , manager , Sales , and Workers .

SAS PROC REPORT With Selected Columns

PROC REPORT With WHERE Clause

You can add filters on your SAS dataset using standard where statement and report procedure will generate output reports based on selected rows.

This example creates the report output with selected four variables described in the previous example but only on selected rows ( region 2 and 3 ) by where clause.

SAS PROC REPORT With WHERE Clause

How To Customise PROC REPORT Columns

PROC REPORT procedure generates reports with default column formats. It can be changed and adjusted the way you wanted to display using the DEFINE statement with DISPLAY instructions.

You can add labels, set the alignment, and add formats to the output report. This is the extension of the last example but with some customization to the report.

Customization:

  • Column “ Manager ” will be labelled as “ Regional Manager ” and aligned values to the right.
  • Column “ Sales ” will be labelled as “ Sales Amount ”. Also, applied format dollar12. on column values.

How To Customise Columns in SAS PROC Report

PROC REPORT With The User Defined Formats

As a part of customization for proc report output you can create special user defined formats and use it in the proc report procedure to show formatted values in the report.

We have already seen how to use SAS inbuilt formats in the previous example where format=dollar12. is applied to the “ Sales ” column.

This example is focused more on creating your own user defined format and using it in the proc report procedure to format column values.

If you see region values are 1, 2, 3, and so on in the input dataset. The same has been printed in the output report.

Does it represent different regions?

What exactly are those regions?

You can’t tell looking at the report.

To add more context to this you can create a format for regions and apply them on the “ region ” variable to print actual region names.

Here is how you can create format:

Now you have region format “ REGIONFMT ” ready to use it in the proc report procedure with the DEFINE statement followed by FORMAT=user-defined-format

We will continue with the same example but with applying this regionfmt format on “ region ” variable and see the output result.

SAS User defined format in proc report procedure in sas

How To Group Data In The PROC REPORT

As with the DEFINE statement you can use a DISPLAY statement to format columns in a report, similarly you can use the GROUP statement with variable on which data to be grouped and displayed. 

In the below example data is grouped by regions and presented with the formatted values for regions instead of original values using the format=regionfmt.

How To Group Data In the PROC REPORT in SAS

How To Summarize Data In The PROC REPORT

In order to summarize the data and create summary statistics, you need to first define a report-item, which must be a data set variable, as an analysis variable.

And also specify what statistics you want to calculate. This example demonstrates “ Sales ” as an analysis variable and SUM will be calculated. Alternatively, you can also specify MIN , MAX , MEAN , or STD , etc. to calculate statistics you want to compute.

Let’s continue with the same previous example with column, group, format=, statements and explain how summation works in the proc report in SAS.

How To Summarize Data In the PROC REPORT

How To Transpose Report Dataset In PROC REPORT

Sometimes you may want to transpose the report dataset to make it more readable and informative.

You can do this within the proc report procedure without actually modifying or creating a separate transpose dataset using ACROSS statemen t .

You must define a report-item, which must be a data set variable, as an across variable. Let’s try to transpose the output displayed in the previous example by setting “ region ” as across variable.

How to transpose proc report output dataset in SAS

How To Create Grouped Columns In The PROC REPORT

In the continuation of the previous example, let’s try to group columns in the proc report to display the sum of sales of each department along with the number of workers working there.

The report is grouped by region and departments , calculated and displayed sum of sales and number of workers.

How to create grouped columns in the PROC REPORT

How To Add TOTAL In The PROC REPORT

Now you have calculated the sum of sales with the grouped columns by department to show sales and number of workers working in each department per region. After this you might want to add the last row with the TOTAL of each numeric column. 

You’ll get the total number of workers working in each region, sum of sales for each region. Which needs to be calculated while SAS builds the report dataset. It can be done using COMPUTE BLOCK . 

A compute block contains one or more programming statements that PROC REPORT executes as it builds the report. You also need to use RBREAK AFTER /SUMMERIZE – It includes a summary line as one of the break lines.

In this example naturally you would like to see total from each department hence it is wise to add the label “ TOTAL ” on the department variable within the compute block.

How To Add TOTAL In the PROC REPORT

PROC REPORT With Conditional Formatting In SAS

The following simple example demonstrates how to add conditional formatting on variable “ Sales ” based on its value. The cells with blank Sales values or up to 199 will be highlighted with light red color and the cells with sales values more than 200 will be highlighted with light green color . 

With the above information let’s first create a user defined format called “ mycolorFMT ”.

Furthermore in the below example a compute block is used to call a DEFINE statement to format the variable “ Sales ” values based on the above created user defined format “ mycolorFMT ”. You can add even more style attributes but for now I have just added background=mycolorFMT.

PROC REPORT Conditional Formatting in SAS

How To Style PROC REPORT In SAS With Colours

To create customized style proc report output in SAS you need to use STYLE=options .

You can use the STYLE=option to set the style element for the entire report, for all the report columns, for the column headings, for the compute block lines, for the report summaries, or on the specific report cell with conditional formatting.

  • style(report) : Set the style element for the report
  • style(column) : Set the style element for the report columns
  • style(header) : Set the style element for the column headings

In this example also we have used user defined regionFMT created earlier in the article.

PROC REPORT How to style a report in SAS

Create PDF File With PROC REPORT Output In SAS

You can print the proc report result to a PDF file in SAS. The ODS option can be used in SAS. You need to add an ODS PDF statement in the beginning of your code by specifying output file details and add an ODS PDF close statement at the end.

We will use the same earlier example to create a PDF file with proc report output using the ODS PDF statement.

Create PDF file With PROC REPORT Output in SAS

Create RTF File With PROC REPORT Output In SAS

You can print the proc report result to a RTF (Rich Text Format) file in SAS. ODS option can be used in SAS to create this document. With ODS, you can create various file types including HTML, Rich Text Format (RTF), PostScript (PS), Portable Document Format (PDF), and SAS data sets.

You need to add an ODS RTF statement in the beginning of your code by specifying output file details and add an ODS RTF close statement at the end.

We will use the earlier example and put the result into an RTF file using the ODS RTF statement.

Create RTF file With PROC REPORT Output in SAS

ADDITIONAL RESOURCES:

  • SUBSTR in SAS (Ultimate Guide with Examples)
  • How To Select The First N Rows In SAS
  • 7 ways to add comments in SAS
  • How to Use First. and Last. Variable In SAS
  • How To Create Beautiful Maps In SAS

FAQ – PROC REPORT In SAS

PROC REPORT is a SAS procedure that generates tabular reports with more advanced features than PROC PRINT. It provides a flexible and powerful way to create custom reports that can include summary statistics, computed columns, and complex formatting.

To use PROC REPORT in SAS, you need to specify the data set to be used, the variables to be included in the report, and the summary statistics to be computed.

You can also customize the output by using various options such as the COLUMN statement, the DEFINE statement, and the COMPUTE block.

PROC REPORT provides a flexible and powerful way to create custom reports that can include summary statistics, computed columns, and complex formatting.

It also allows you to create reports that are tailored to your specific needs and can be easily updated as your data changes.

To customize the output of PROC REPORT, you can use various options such as the COLUMN statement, the DEFINE statement, and the COMPUTE block.

These options allow you to control the appearance of the output and the statistics that are displayed.

Statology

Statistics Made Easy

How to Use Proc Report in SAS (With Examples)

You can use proc report in SAS to generate a report for a dataset in SAS with the exact formatting that you’d like.

This procedure uses the following basic syntax:

This will generate a report that displays the rows in a dataset exactly as they appear.

However, you can customize the output of the report in a variety of ways.

For example, we can use the following syntax to create a more customized report:

Here’s what each statement does:

  • title creates a title for the report
  • where filters the dataset to only contain rows where team is ‘Mavs’
  • column specifies which columns to display in the report in a certain order
  • display specifies the title to use for the column called conf and center specifies the text to be centered in the column

The following example shows how to use proc report in practice.

Note : Refer to the online documentation for a complete explanation of all the ways you can customize a report.

Example: Using Proc Report in SAS

Suppose we have the following dataset in SAS that contains information about various basketball players:

sas proc report page x of y

We can use proc report in the following manner to print the entire dataset as it appears:

sas proc report page x of y

The report simply contains the entire dataset.

However, we can use proc report to generate a customized report by using the following syntax:

sas proc report page x of y

Notice that this report contains the following differences compared to the original report:

  • This report has a title
  • This report only contains rows where team is ‘Mavs’
  • This report only contains the conf, team, and points columns
  • This report uses ‘Conference’ as the title for conf and center-aligns the values in the conf column

This is just a simple example of how to create a customized report using proc report in SAS.

Feel free to explore the online documentation to see how you can further customize the output and generate a report that appears exactly how you’d like in SAS.

Additional Resources

The following tutorials explain how to perform other common tasks in SAS:

How to Use Proc Append in SAS How to Use Proc Tabulate in SAS How to Use Proc Summary in SAS

Featured Posts

5 Regularization Techniques You Should Know

Hey there. My name is Zach Bobbitt. I have a Masters of Science degree in Applied Statistics and I’ve worked on machine learning algorithms for professional businesses in both healthcare and retail. I’m passionate about statistics, machine learning, and data visualization and I created Statology to be a resource for both students and teachers alike.  My goal with this site is to help you learn statistics through using simple terms, plenty of real-world examples, and helpful illustrations.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the Statology Community

I have read and agree to the terms & conditions

  • CDISC Standards
  • SAS® Job Aids

PROC REPORT         

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.

  • Beginner_SAS_Programmer
  • Advanced_SAS_Programmer
  • Macro_SAS_Programmer

Proc Report Map

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 proc report page x of y

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

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

 COMPUTE;  ENDCOMP;

 BREAK;  RBREAK; RUN;

Proc Report Gallery

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

SAS Course Notes A Tutorial on Proc Report, Cynthia Zender

RTF Control Words Reference

See Top Pharmaceutical Industry Papers section for more Proc Report examples

Default Proc Report Listing

sas proc report page x of y

IMAGES

  1. two columns in dataset to two rows in PROC REPORT?

    sas proc report page x of y

  2. PROC REPORT in SAS|Combining the power of PROC TABULATE, PROC FREQ

    sas proc report page x of y

  3. SAS Savvy

    sas proc report page x of y

  4. Proc Template Sas

    sas proc report page x of y

  5. A Step-By-Step Introduction to SAS Report Procedure

    sas proc report page x of y

  6. SAS Online Training

    sas proc report page x of y

VIDEO

  1. SAS Proc Geocode Basics

  2. SAS Interview Question and Answers 8

  3. What Is Clean Patient Data

  4. What Is Blinding

  5. Optimization in SAS

  6. SAS:Processing statements conditionally at macro level

COMMENTS

  1. to insert pagenumbers x of y, using proc report

    Re: to insert pagenumbers x of y, using proc report. It uses ODS ESCAPECHAR. An afterthought: The Page X of Y technique shown in the above post is a feature of ODS that can be used in a SAS title or SAS footnote statement -- that means you could use the capability with ANY SAS procedure -- not just PROC REPORT.

  2. PDF Page X of Y with Proc Report

    Despite the flexibility, however, doing the "page X of Y"-style page numbers remains non-trivial. SAS Institute has come out with a macro to post-process PROC REPORT output (SAS Institute(a)). Many users, also, have devised means to pre- or post-process data so that this can be done. We introduce one of our own, which is simpler and more

  3. In ODS RTF, can I get my page numbers in page X of Y format?

    In SAS 9 and later, the experimental in-line formatting function {PAGEOF}, produces page X of Y numbering with Word 2000 and higher. Prior to SAS 9, you can add raw RTF code in the TITLE or FOOTNOTE statement. Below is an example of both. View output of the SAS 8.2 example. /* SAS 8.2 */. /* CAUTION: Make sure the raw RTF code is on ONE line ...

  4. PDF A Simple Approach to Generate Page Numbers in X of Y Format in ODS RTF

    A Simple Approach to Generate Page Numbers in X of Y Format in ODS RTF Output Amos Shu, Endo Pharmaceuticals., Chadds Ford, PA ABSTRACT Page numbers in X of Y format, such as "Page 18 of 280", "Page 2 of 30", are a common feature of ODS RTF outputs. The "X" indicates the current page number, and the "Y" is the total number of pages.

  5. Proc Report 'page x of y' together with PAGE option

    Re: Proc Report 'page x of y' together with PAGE option. In SAS 9.1, ODS RTF does not do vertical measurement -- so the control for the page break behavior is left to Word. One person could open the report, set one set of margins and they would see different page numbering than another person who opened the report and set different margins.

  6. Page X of Y

    Re: Page X of Y. Posted 02-27-2008 08:23 PM (804 views) | In reply to BrunoSilva. Hi: In order for the footnote statement to work, you must declare what the ODS ESCAPECHAR value is. ODS ESCAPECHAR is the special character that lets ODS know that you want to do something special (like use the {thispage} and/or {lastpage} Escapechar functions.

  7. PDF Jazzing up Your Reports

    These are how to: break up sections of the report with solid lines. number the pages of report in the form 'Page x of y' immediately at the foot the report. add footnotes conditional on the contents of the current page of the report. In this paper I will show you how put these in my reports. All examples in this paper have been tried and ...

  8. PDF Creating Word Tables using PROC REPORT and ODS RTF

    • Page numbering (Page X of Y) • The bodytitle option and its effect on headers, titles, footnotes and page numbering • Breaking a page The need to produce tables that can be inserted directly into document text (in-text tables) for study reports, etc., motivated me to learn how to use PROC REPORT and ODS RTF to produce Word tables.

  9. PDF Carpenters Complete Guide to the SAS Report Procedure

    Carpenter's Complete Guide to the SAS REPORT Procedure. Sample 634: Wrapping values of a long variable onto multiple lines within the width of the variable's column using PROC REPORT . Sample 635: Specify one or more ID variables to print on each page in PROC REPORT . Sample 637: Wrapping observations that are too long to fit in PROC REPORT

  10. How to repeat a column on every page using PROC REPORT

    Sample 25118: How to repeat a column on every page using PROC REPORT. If a report has too many variables to print across a single page, the ID option can be used in the DEFINE statement of one or more variables. This forces the variable (s) to print on each page when wrapping occurs. If additional control over pagination is desired, the PAGE ...

  11. PROC REPORT: PROC REPORT Statement

    PROC REPORT honors the line size specifications that it finds in the following order of precedence: the LS= option in the PROC REPORT statement or LINESIZE= in the ROPTIONS window. the LS= setting stored in the report definition loaded with REPORT= in the PROC REPORT statement. the SAS system option LINESIZE=.

  12. How to print a page number (page X of Y) in body part ...

    Re: How to print a page number (page X of Y) in body part of footnote with rtf tags. You have a typo in that: ods RTF TEXT= "^R/RTF {'/sectd /pgnstart'}"; Don't think this will help though, it may (you will have to try) reset the page numbering back to 1, but its still a calculated not fixed page numbering.

  13. 24438

    Usage Note. 24438: Customizing page numbers in the ODS PDF destination. Beginning with SAS ® 9.1, page numbers can be customized in PDF output by using an escape character and the {thispage} function, {lastpage} function, or both. For example: do i=1 to 50; output; end;

  14. SAS Help Center: Overview: PROC REPORT

    This overview illustrates the types of reports that PROC REPORT can produce. The statements that create the data sets and formats used in these reports are in Selecting Variables and Creating a Summary Line for a Report. The formats are stored in a permanent SAS library. See the REPORT procedure examples for more reports and for the statements ...

  15. PROC REPORT In SAS (With 15+ Examples)

    PROC REPORT In SAS (With 15+ Examples) November 19, 2023 by SAS User. PROC REPORT statement combines features of the PROC PRINT, PROC MEANS, and PROC TABULATE procedures with features of the DATA step in a single report-writing tool that can produce a variety of reports. You can use PROC REPORT procedure to create a report with the SAS dataset ...

  16. page x of y

    Re: page x of y. That might be a question for Tech Support or something to post in the Stored Process forum. You can make a package file (a SAS Package file generally has the extension .spk -- and is like a zip archive) from a stored process and the package file could hold multiple PDF files.

  17. Page X of Y in PROC Report in UNIX

    titles were used, or the nonumber option was in effect, you can use the. LS parameter to explicitly set the linesize used to justify the page. renumbering. By default the "Page x of Y" output is right justified using this. derived linesize. Use the JUSTIFY parameter to override the default. justification.

  18. PDF An Introduction to PROC REPORT

    Create a horizontal line between the column headers and the body of the report. Create a blank line between the column headers and the body of the report. Suppress the REPORT window and direct the report output to open ODS destinations. Create an output SAS data set. Specify a location to store the report.

  19. 15727

    Usage Note. 15727: Writing "PAGE X of Y" in ODS RTF does not work with the BODYTITLE option. Raw RTF code or the inline style function PAGEOF can be used in a TITLE or FOOTNOTE statement to write "PAGE X of Y" text in RTF output. However, if the BODYTITLE option is also used in the ODS RTF statement, the PAGEOF information is not written as ...

  20. How to Use Proc Report in SAS (With Examples)

    This procedure uses the following basic syntax: /*create report*/. proc report data=my_data; run; This will generate a report that displays the rows in a dataset exactly as they appear. However, you can customize the output of the report in a variety of ways. For example, we can use the following syntax to create a more customized report ...

  21. SAS Help Center: Syntax: PROC REPORT PROC REPORT Statement

    Interaction. PROC REPORT uses the value of the SAS system option THREADS except when a BY statement is specified or the value of the SAS system option CPUCOUNT is less than 2. You can specify the THREADS option in the PROC REPORT statement to force PROC REPORT to use parallel processing in these situations. Note.

  22. PDF The SAS Programmer's PROC REPORT Handbook

    compute discount; if order_type in (1 2) then do; qnt1 + quantity.sum; end; endcomp; compute seetempvar; seetempvar = qnt1; endcomp; run; Add SEETEMPVAR to the COLUMN statement. This report-item will hold the value of the temporary variable created in a compute block.

  23. SAS Savvy

    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.

  24. Proc Report

    Hi all - I have a specific report format that I am trying to achieve using PROC REPORT, and I'm getting pretty close, but there's a column subtotal element that I cannot figure out. I have sales data, summarized by Client, Quarter, and Week. Each quarter contains an arbitrary number of weeks, up ...