Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Proc Report Tricks In SAS, easy methods to learn sas proc report procedure
Description: Easy way to learn proc report procedure, it's very important document to learn proc report procedure

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Paper 109 – 2010

Thirty Three Tricks with PROC REPORT:
A Quick Introduction to the Powerful REPORT Procedure
Ben Cochran, The Bedford Group, Raleigh, NC
Abstract
When the REPORT Procedure was first introduced by SAS with the advent of Version 6, most of the SAS world was
mainframe users
...
It had powerful formatting, summarizing, and analysis capabilities
that made it easier to create many different kinds of reports from a simple listing to a very complex report
...
That was
true until SAS released the Output Delivery System (ODS) experimentally in Version 7, and in production mode in
Version 8
...

This paper offers a quick overview of the types of reports that can be generated with Proc REPORT, and how to
add some of the ODS features to deliver stunning reports
...
First, a
look is taken at the general syntax, and then a series of reports will be generated starting with a very simple report
and then working up to more complex reports
...

PROC REPORT data= SAS-data-set options ;
COLUMNS variable_1 …
...

DEFINE variable_n;
COMPUTE blocks
BREAK … ;
RBREAK … ;
RUN;
COLUMNS statement defines which columns appear in the report, and their order
...

COMPUTE blocks allow calculations to be performed in the report
...

The REPORT procedure also has many options that can be used
...
CLASS
data set
...


Program 1
...
The term following the ‘/’ specifies the way the REPORT procedure uses the
column
...

Now, lets look at the output created from the above program
...

At first glance, this looks a little like PROC PRINT output without the OBS column
...


Trick 2: Add a Compute Block and a total row at the end of the report
...

You can see the new column, ratio, as well as the averages for Height, Weight and ratio at the end of the report
...

Notice the columns defined as ANALYSIS and COMPUTED have MEANS generated with the RBREAK statement
...
Why is there no AVERAGE for age at
the end of the report?

Trick 3: Generate subtotals and add a blank line after each gender
...

Notice the BREAK statement and its options
...

Look at the definition of age; it has been changed from display to analysis
...

Notice that the order of the variables have rearranged
...
Sex has been
redefined as a GROUP variable
...


Trick 4: Calculate Percentages with PROC REPORT
...
In this case, the percentages
are to add up to 100 for each group
...


4

Program 4
...
The second one creates weight_sum which is the total weight for each group
...
Also notice that the statistic has been
dropped from the DEFINE statement for weight
...


5

Notice the weight column
...
Is the subtotal for weight really realistic for this report? Maybe not, but it is needed here to calculate the
percents
...
Is there a
way to do this in PROC REPORT?

Trick 5
...


Partial Program 5
...


Partial Output 5
...
But what if we wanted a column showing weight, and subtotals
showing the average weight for each group in addition to the weight % column
...
Add a column to display weight and its AVERAGE for each group
...


Notice the ‘weight = weight2’ in the COLUMNS statement
...
The statistic for weight defaults to sum
and is used in calculating percentages, but is not displayed in the report because of the NOPRINT definition
...


Partial Output 6
...

Up to this point, the report has only shown a single statistic for each column
...
Can this be done with PROC REPORT?

Trick 7
...

In order to calculate multiple statistics for each column, we are going to have to manipulate the data
...
In other words, in this example, two
statistics are displayed
...
class;

7

gender = sex;
run;
Once the data is manipulated, it can now be processed by the REPORT procedure
...


Notice there is the weight column and two alias’: weight_md and weight_mn
...

You can only calculate one row (statistic) for each column in a compute block
...
So, if you want two statistics for each column, then you need two compute
blocks, but they have to be for different variables
...
Both have the same values for each row
...
Notice the assignment statement for name in each
...
Partial REPORT Procedure output

Trick 8
...

8

In this example, we want to see multiple averages calculated for the same column
...
In order to accomplish
this task, the data set will have to be pre-processed again
...

data prep2;
length name $15
...
class;
f = 1;
m = 1;
goal = 99;
run;
You can use what some programmers call ‘holding variables’ in PROC REPORT
...


Partial REPORT Procedure, Program 8
...

The variable wholdm and wholdf are ‘holding variables’, you can use them in calculations, but they do not appear
in the report
...
Notice the output
...


Trick 9
...

With the Output Delivery System, you can send your output to any number of locations as well as create special
formatting
...


ods listing close;
ods rtf file = ‘c:\sugi30
...
The
third one closes the rtf file
...
ODS
...
Also notice other aesthetic considerations
Such as the color of the fonts, and background color of each of the cells
...


Trick 10
...

With ODS comes some new features in the syntax, including the STYLE( area )= option, where area = some part of
the report
...
We are going
to put the STYLE(area)= option to work on the PROC statement first
...
Also notice which attributes are going to be effected
...


11

The rest of PROC REPORT is the same as it was for the previous task except for the BREAK and the RBREAK
statements
...
Also notice that because they are on a BREAK or RBREAK statement, they do not have the area in
parenthesis
...

The effects of these style options can be seen in the output below
...
The higher the level of detail, the smaller the font
...


Hopefully, this output will give you some ideas of the possibilities that are available with the ODS
...


12

Output 10
...


CONTACT INFORMATION
Your comments and questions are valued and encouraged
...
741
...
rr
...
product or service names are registered trademarks or trademarks of SAS
Institute Inc
...
® indicates USA registration
...


13


Title: Proc Report Tricks In SAS, easy methods to learn sas proc report procedure
Description: Easy way to learn proc report procedure, it's very important document to learn proc report procedure