The script begins by creating an internal dataset 'one' via a DATA step with inline data. It then sets up macro variables for the ODS panel and initializes ODS TAGSETS.HTMLPANEL to generate an HTML file named 'gtfpanel.html'. Graphics options (GOPTIONS) are defined to specify the driver and dimensions, and footnotes are specified. Four PROC GCHART graphs are generated from the SASHELP.CLASS dataset and are automatically panelized in the HTML output. A simple table is then displayed with PROC PRINT from the 'one' dataset. Finally, an additional PROC GCHART graph is generated with grouping by the 'z' variable from the 'one' dataset, demonstrating by-group titles and footnotes. The script concludes by disabling embedded titles and closing all ODS destinations.
Data Analysis
Type : MIXTE
The script uses an internally created dataset ('one') via a DATA step with inline data, and the SASHELP.CLASS system dataset.
1 Code Block
DATA STEP Data
Explanation : Creates a dataset named 'one' with three variables (x, y, z) and inserts inline defined data (datalines).
Explanation : Defines macro variables to control the panel display (number of columns, border, embedded titles) and opens the ODS TAGSETS.HTMLPANEL destination to generate an HTML file named 'gtfpanel.html' in the current directory.
Explanation : Configures global graphics options, specifying the 'javaimg' device driver and pixel dimensions. Also defines two footnotes that will be used for subsequent graphs.
Copied!
goptions dev=javaimg xpixels=480 ypixels=320;
/* Footnote stuff */
footnote1 "A footnote";
footnote2 "A second footnote";
1
goptions dev=javaimg xpixels=480 ypixels=320;
2
3
/* Footnote stuff */
4
footnote1 "A footnote";
5
footnote2 "A second footnote";
4 Code Block
PROC GCHART
Explanation : Starts ODS panelization. Generates four bar charts (vertical and horizontal) from the `sashelp.class` dataset using PROC GCHART. Each chart receives a distinct title. These charts are automatically organized into a panel in the HTML output. Panelization is stopped after the graphs are generated.
Explanation : Displays the content of the 'one' dataset as a table, with the title 'A PROC PRINT Table'.
Copied!
title1 "A PROC PRINT Table";
proc print data=one;
run;
1
title1 "A
2
PROC PRINT Table";
3
PROC PRINT
4
DATA=one;
5
RUN;
6
6 Code Block
PROC GCHART
Explanation : Defines dynamic by-group title and footnote. Generates a vertical bar chart from the 'one' dataset, grouped by the variable 'z'. For each group of 'z', it displays a bar for each value of 'x', where the height of the bar represents the sum of 'y'.
Copied!
title1 'By-group title for z=#byval(z)';
footnote1 'By-group footnote for z=#byval(z)';
proc gchart data=one;
by z;
vbar x / sumvar=y pattid=midpoint discrete;
run;
quit;
1
title1 'By-group title for z=#byval(z)';
2
footnote1 'By-group footnote for z=#byval(z)';
3
4
PROC GCHARTDATA=one;
5
BY z;
6
vbar x / sumvar=y pattid=midpoint discrete;
7
RUN;
8
QUIT;
7 Code Block
ODS Cleanup
Explanation : Resets the `embedded_titles` macro variable to 'no' and closes all currently open ODS destinations, thus finalizing the creation of the output files.
Copied!
%let embedded_titles=no;
ods _all_ close;
1
%let embedded_titles=no;
2
3
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.