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!
options center;
ods listing close;
ods html style=default
path="&path\results"
body='E8_1.html';
1
options center;
2
ods listing close;
3
4
ods 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!
title1 'Total profit per year';
title2 'Separated by Product Line';
title3 'Profit Summaries';
proc report data=sashelp.orsales nowd split='*'
style(header)={background=white}
style(column)={background=pink};
column year product_line profit;
define year / group
style(header)={background=yellow}
style(column)={background=cyan};
define product_line
/ group
'Product*Groups';
define profit / analysis
sum format=dollar15.2
'Annual*Profit';
break after year / summarize suppress skip
style(summary)={background=green};
rbreak after / summarize
style(summary)={background=red};
run;
1
title1 'Total profit per year';
2
title2 'Separated by Product Line';
3
title3 'Profit Summaries';
4
PROC REPORTDATA=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!
ods _all_ close;
1
ods _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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.