Published on :
Reporting SASHELP

ODS HTMLPanel Report with PROC PRINT and PROC GCHART

This code is also available in: Deutsch Español Français
Awaiting validation
The script begins by configuring graphics options and initial ODS TAGSETS.HTMLPANEL settings, including the HTML file destination and the number of columns for the panels. It then executes several PROC PRINT statements on the SASHELP.CLASS table, grouped into panels. Panel options are modified during execution. A PROC SORT is used to sort SASHELP.CLASS by age, creating a new temporary table, which is then visualized with PROC GCHART to display the sum of weight relative to height, grouped by age. The script concludes by closing all ODS destinations.
Data Analysis

Type : SASHELP


The script exclusively uses the SASHELP.CLASS table, a standard demonstration table built into SAS, and creates a temporary table 'WORK.FOO' from it for sorting and graphing operations.

1 Code Block
GOPTIONS & ODS HTMLPANEL Setup
Explanation :
Configures graphics options for GIF output with specified dimensions. Initializes the ODS TAGSETS.HTMLPANEL destination to create a paginated HTML report with panels, defining the output file ('printpanel2.html') and several panel display options such as the number of columns, borders, and title management.
Copied!
1goptions dev=gif xpixels=480 ypixels=320;
2 
3ods tagsets.htmlpanel nogtitle file="printpanel2.html"
4 options(panelcolumns='3'
5 panelborder='2'
6 embedded_titles='yes'
7 bylabels='no');
2 Code Block
PROC PRINT
Explanation :
Starts a new group of ODS HTML panels. Three consecutive PROC PRINT statements are executed on the SASHELP.CLASS table, each preceded by a distinct title. Each PROC PRINT output is encapsulated in a separate panel. The panel group is then closed.
Copied!
1/* start the panelling */
2 
3ods tagsets.htmlpanel event = panel(start);
4 
5title 'First proc Print';
6 
7PROC PRINT DATA=sashelp.class;RUN;
8 
9title 'Second proc Print';
10PROC PRINT DATA=sashelp.class;RUN;
11 
12title 'Third proc Print';
13PROC PRINT DATA=sashelp.class;RUN;
14 
15 
16/* Stop the current Panel */
17ods tagsets.htmlpanel event = panel(finish);
3 Code Block
PROC SORT & PROC GCHART Data
Explanation :
Modifies HTML panel options, reducing the number of columns to 2 and disabling embedded titles. The SASHELP.CLASS table is sorted by the 'age' variable and the result is saved in a new temporary table named 'foo'. Then, PROC GCHART generates a horizontal bar chart from the 'foo' table, grouped by 'age', displaying the sum of 'height' by 'weight'.
Copied!
1/* Change the panel settings */
2 
3ods tagsets.htmlpanel options(panelcolumns='2'
4 embedded_titles='no');
5 
6/* this bygroup get's a panel of it's own. */
7 
8title ;
9 
10PROC SORT DATA=sashelp.class out=foo;
11 BY age;
12 RUN;
13
14PROC GCHART DATA=foo;
15 BY age;
16 hbar weight / sumvar=height;
17RUN;
18QUIT;
4 Code Block
PROC PRINT
Explanation :
Starts a new group of ODS HTML panels. Two more PROC PRINT statements for SASHELP.CLASS are executed. The first has a simple title, while the second includes both a title and a footnote. The panel group is then closed.
Copied!
1/* start a new, semi-automatic panel */
2ods tagsets.htmlpanel event = panel(start);
3 
4title 'Fourth proc Print';
5PROC PRINT DATA=sashelp.class;RUN;
6 
7title 'Fifth proc Print';
8Footnote 'End of Fifth proc Print';
9PROC PRINT DATA=sashelp.class;RUN;
10 
11ods tagsets.htmlpanel event = panel(finish);
5 Code Block
ODS Closure
Explanation :
Closes all ODS destinations that were opened during script execution, ensuring output files are finalized.
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.