Published on :
Reporting SASHELP

ODS Report of Profits by Year and Product

This code is also available in: Deutsch Español Français
This script produces an HTML file ('E8_1.html') containing a summary table based on 'sashelp.orsales' data. It uses the REPORT procedure to sum profits, grouped by year and product line. Specific styles (background colors) are applied to headers, columns, as well as to subtotal lines (by year) and the grand total.
Data Analysis

Type : SASHELP


Use of the standard 'sashelp.orsales' table provided with SAS.

1 Code Block
ODS
Explanation :
Environment configuration: centering the output, closing the LISTING destination, and opening the ODS HTML destination. The output file is directed to a path defined by the &path macro variable.
Copied!
1options center;
2ods listing close;
3 
4ods html style=default
5 path="&pathesults"
6 body='E8_1.html';
2 Code Block
PROC REPORT
Explanation :
Execution of PROC REPORT to create the table. DEFINE statements configure groups (year, product_line) and analysis (sum profit). BREAK and RBREAK statements add summary lines after each year and at the end of the report, with distinct background styles (green and red).
Copied!
1title1 'Total profit per year';
2title2 'Separated by Product Line';
3title3 'Profit Summaries';
4PROC REPORT DATA=sashelp.orsales nowd split='*'
5 style(header)={background=white}
6 style(column)={background=pink};
7 column year product_line profit;
8 define year / group
9 style(header)={background=yellow}
10 style(column)={background=cyan};
11 define product_line
12 / group
13 'Product*Groups';
14 define profit / analysis
15 sum FORMAT=dollar15.2
16 'Annual*Profit';
17 break after year / summarize suppress skip
18 style(summary)={background=green};
19 rbreak after / summarize
20 style(summary)={background=red};
21 RUN;
3 Code Block
ODS
Explanation :
Closing all ODS destinations to finalize the creation of the HTML file.
Copied!
1ods _all_ close;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.