PROC REPORT Unwrapped: Exploring the Secrets behind One of the Most Popular Procedures in Base SAS® Software
Allison McMahill Booth, SAS Institute Inc., Cary, NC, USA
Have you ever wondered why a numeric variable is referenced in different forms within a COMPUTE block? Do you know the difference between a DATA step variable and a variable that is listed in the COLUMN statement? Then, this paper is for you! Welcome to PROC REPORT Unwrapped. We are looking at PROC REPORT and uncovering some of the behind-the-scenes details about this classic procedure. We will explore the components associated with PROC REPORT and discover ways to move column headings and change default attributes with styles and CALL DEFINE statements. We will also dig deep into example code and explore the new ability to use multilabel formatting for creating subgroup combinations. So for anyone who has ever written PROC REPORT code, stay tuned. It's PROC REPORT Unwrapped!
Which popular SAS procedure has features of the PRINT, MEANS, and TABULATE procedures and features of the DATA step in a single report-writing tool? It enables you to create a variety of reports including a detail report, which contains a row of data for every input data set observation, or a summary report, which consolidates data so that each row represents multiple input data set observations. Here is another hint: this same procedure provides the ability to create both default and customized summaries, add text and statistics, and create columns of data that do not exist in the input data set. If you guessed PROC REPORT, you are correct! For anyone who has written PROC REPORT code and has wondered what is going on behind the scenes, this is the paper for you. This paper explores some of the behind-the-scenes secrets of PROC REPORT. We will dig deep into example code as we begin to uncover some of the details of this classic report-writing procedure. As a bonus, you will discover some facts about the REPORT procedure that you might not have known. By the way, the code output in this paper is based on the SAS® 9.3 default output destination of HTML. Although most of the paper content can also be applied to the LISTING destination, the code that is shown in this paper is intended to be used in an Output Delivery System (ODS) destination, unless otherwise indicated. With that being said…are you ready to explore? Welcome to PROC REPORT Unwrapped!
EXPLORING THE SECRETS (HOW IT’S MADE)
PROC REPORT first began life as a procedure many years ago in SAS® 6. Since then, it has been gaining popularity as the tool of choice for report writing. Even with such popularity, there are still aspects of the REPORT procedure that can be further explored. In this segment, we will unwrap and explore some of the secrets behind this most popular procedure with a focus on the following components:
referencing a numeric variable in a COMPUTE block
exploring the difference between an input data set variable and a DATA step variable
discovering ways to move column headings
changing default attributes with styles
using the CALL DEFINE statement
exploring the new ability in SAS 9.3 to use multilabel formatting for creating subgroup combinations
Let’s start exploring the secrets!
REFERENCING A NUMERIC VARIABLE IN A COMPUTE BLOCK
All numeric variables are referenced the same way, right? Well, that depends on how the numeric variable is defined in the PROC REPORT DEFINE statement. Before we can explore more about the how a numeric variable is defined, we first need to understand some PROC REPORT basics. Then we will explore the many ways a numeric variable
PROC REPORT Unwrapped: Exploring the Secrets behind One of the Most Popular Procedures in Base SAS® Software, continued
can be defined in the DEFINE statement and how that definition determines the manner in which the variable is...