The script begins by setting system options and closing default ODS outputs. It then configures ODS output to HTML to a specified file. The PROC REPORT procedure is used to aggregate data from the `sashelp.orsales` dataset. The 'year' and 'product_line' variables are defined as grouping variables, and 'profit' is summed. Breaks are defined after each year and at the end of the report to display totals. Conditional styles are applied to rows and columns to improve report readability.
Data Analysis
Type : SASHELP
The report is built from the `orsales` dataset in the SASHELP library. This dataset is a standard example provided by SAS, requiring no specific external data or internal data creation within the script.
1 Code Block
PROC REPORT / ODS
Explanation : This block first configures the report titles and ODS options to generate a stylized HTML output. The `PROC REPORT` procedure is then invoked on the `sashelp.orsales` dataset. It defines columns, grouping variables (`year`, `product_line`), and an analysis variable (`profit`) which is summed and formatted. The `break` and `rbreak` statements add summary rows for intermediate totals by year and a grand total. The `compute` blocks apply color styles (cyan, pink, green, red) to headers and summary rows via the `call define` function, enhancing the report's visual presentation.
Copied!
options center;
ods listing close;
ods html style=default
path="&path\results"
body='E8_2.html';
title1 'Total profit per year';
title2 'Separated by Product Line';
title3 'Profit Summaries';
proc report data=sashelp.orsales nowd split='*';
* Call define does not offer control of the header spaces
* style(header)={background=white}
* style(column)={background=pink};
column year product_line profit;
define year / group;
define product_line
/ group
'Product*Groups';
define profit / analysis
sum format=dollar15.2
'Annual*Profit';
break after year / summarize suppress skip;
rbreak after / summarize;
compute year;
call define(_col_,'style','style={background=cyan}');
endcomp;
compute product_line;
call define(_col_,'style','style={background=pink}');
endcomp;
compute after year;
call define(_row_,'style','style={background=green}');
endcomp;
compute after;
call define(_row_,'style','style={background=red}');
endcomp;
run;
ods _all_ close;
1
options center;
2
ods listing close;
3
4
ods html style=default
5
path="&pathesults"
6
body='E8_2.html';
7
8
title1 'Total profit per year';
9
title2 'Separated by Product Line';
10
title3 'Profit Summaries';
11
PROC REPORTDATA=sashelp.orsales nowd split='*';
12
* Call define does not offer control of the header spaces
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.