Master SAS in 30 days!

A jargon-free, easy-to-learn SAS base course that is tailor-made for students with no prior knowledge of SAS.

Lesson 7.2: Proc Report​

PROC REPORT function allows more flexibility in displaying the data
 
Example

This is the exact same dataset we used in the previous section. We are going to display the data using the PROC REPORT function. 

PROC REPORT DATA=Perf;

COLUMN Agent Q1 Q2 Q3 Q4;

DEFINE Agent / display “AGENT” width=6;
DEFINE Q1 / display “FIRST QUARTER” width=14; 
DEFINE Q2 / display “SECOND QUARTER” width=14;  
DEFINE Q3 / display “THIRD QUARTER” width=14;  
DEFINE Q4 / display “FOURTH QUARTER” width=14;  

RUN;  

(1) COLUMN statements list out all of the variables to be displayed in the output. In our example, we have 5 variables: Agent and the performance from each quarter.

(2) DEFINE statement defines the properties of how the variables should be displayed. 

(3) DISPLAY tells SAS to just display the content of the variable. Other options here include: GROUP, ANALYSIS, COMPUTED, ORDER and ACROSS. 

(4) The text within the quotation (e.g. “FIRST QUARTER”) is the label of the variable displayed.

(5) WIDTH assigns the length for each column. This control how the table will look like.


The report still doesn’t look too good. Fortunately, PROC REPORT allows more customization on how the data can be presented. We are going to add 2 commands to our codes above :


PROC REPORT DATA=Perf NOWINDOWS HEADLINE ;

COLUMN Agent Q1 Q2 Q3 Q4;

DEFINE Agent / display “AGENT” width=6;
DEFINE Q1 / display “FIRST QUARTER” width=14; 
DEFINE Q2 / display “SECOND QUARTER” width=14;  
DEFINE Q3 / display “THIRD QUARTER” width=14;  
DEFINE Q4 / display “FOURTH QUARTER” width=14;  

RUN; 

(1) NOWINDOWS statement tells SAS to print the output on the OUTPUT window instead of the PROC REPORT window. This normally allows a clearer presentation of the output.
(2) HEADLINE statement adds a divider between the variable title and the content.


Similar to other procedures, you DO NOT need to memorize the codes. Simply copy the codes from us whenever you need to report the data!

DONE! You have learned the PROC REPORT procedure in SAS! 



Note:
  1. There are a lot more options in PROC REPORT that allow for a far more customized report to be displayed. More details on PROC REPORT will be explained in PART II of this training material.

Master SAS in 30 Days

3.3 4 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
iconmail

Get latest articles from SASCrunch

SAS Base Certification Exam Prep Course

Two Certificate Prep Courses and 300+ Practice Exercises