SAS.GRAPH 9.1 Reference, Volumes I and II

The following sample programs use DEVICE=JAVAMETA to generate metcodes to be displayed by the Metaview applet:

Metacode Output with HTML from ODS

The following sample program uses ODS to create an HTML file, and GOPTIONS DEVICE=JAVAMETA with two instances of PROC GCHART to create graphical output in the form of metacodes. Because both instances of PROC GCHART contain a BY statement, the HTML file created by ODS contains multiple invocations of the applet ”one invocation for each value of the BY statement for each procedure (eight invocations in all). The metacodes produced by PROC GCHART are passed to the applet as a parameter.

When you use DEVICE=JAVAMETA with ODS, only one graph can be passed to an instance of the Metaview applet at a time. ODS generates a separate invocation of the Metaview applet for each SAS/GRAPH procedure that it runs. And, if a procedure includes BY GROUP processing, then it generates another separate invocation of the Metaview applet for each BY- group chart. In sum, Metaview applet presentations generated by ODS never contain a slider page control or drop-down list graph control to allow a user to select which graph is to be displayed. Although an HTML page generated by ODS can contain multiple instances of the Metaview applet, each instance can display one picture only, and a user must scroll the HTML page to see all the pictures.

Each GCHART procedure in this example includes a BY statement to display the results of each of the four quarters of the year. Consequently, ODS generates eight separate invocations of the Metaview applet, only the first of which is shown here. A user would have to scroll the page in the browser to see all four quarters displayed. Notice the slider control at the bottom of the image. Because the image is displayed by the Metaview, the run-time option is available to the user to control the magnification of the chart.

SAS Code

The following is the complete SAS code to generate a Web presentation. You should notice the following:

data prdsummary; input Year Quarter Country . Product . Actual dollar10.2; label Actual = 'Actual Sales'; format Actual dollar11.; datalines; 1993 1 CANADA BED ,337.00 1993 1 CANADA CHAIR ,115.00 1993 1 CANADA DESK ,644.00 1993 1 GERMANY BED ,026.00 1993 1 GERMANY CHAIR ,276.00 1993 1 GERMANY DESK ,330.00 1993 2 CANADA BED ,437.00 1993 2 CANADA CHAIR ,115.00 1993 2 CANADA DESK ,654.00 1993 2 GERMANY BED ,026.00 1993 2 GERMANY CHAIR ,276.00 1993 2 GERMANY DESK ,320.00 1993 3 CANADA BED ,337.00 1993 3 CANADA CHAIR ,145.00 1993 3 CANADA DESK ,614.00 1993 3 GERMANY BED ,026.00 1993 3 GERMANY CHAIR ,276.00 1993 3 GERMANY DESK ,340.00 1993 4 CANADA BED ,337.00 1993 4 CANADA CHAIR ,115.00 1993 4 CANADA DESK ,646.00 1993 4 GERMANY BED ,026.00 1993 4 GERMANY CHAIR ,276.00 1993 4 GERMANY DESK ,350.00 1994 1 CANADA BED ,327.00 1994 1 CANADA CHAIR ,345.00 1994 1 CANADA DESK ,624.00 1994 1 GERMANY BED ,026.00 1994 1 GERMANY CHAIR ,276.00 1994 1 GERMANY DESK ,340.00 1994 2 CANADA BED ,356.00 1994 2 CANADA CHAIR ,115.00 1994 2 CANADA DESK ,623.00 1994 2 GERMANY BED ,026.00 1994 2 GERMANY CHAIR ,276.00 1994 2 GERMANY DESK ,321.00 1994 3 CANADA BED ,321.00 1994 3 CANADA CHAIR ,115.00 1994 3 CANADA DESK ,658.00 1994 3 GERMANY BED ,026.00 1994 3 GERMANY CHAIR ,276.00 1994 3 GERMANY DESK ,398.00 1994 4 CANADA BED ,357.00 1994 4 CANADA CHAIR ,166.00 1994 4 CANADA DESK ,662.00 1994 4 GERMANY BED ,026.00 1994 4 GERMANY CHAIR ,246.00 1994 4 GERMANY DESK ,329.00 ; /* Delete previously created gsegs before creating new ones. */ proc greplay igout=work.gseg nofs; delete _all_; /* Could also specify: delete gchart, gchart1, etc. */ run; quit; ods html file='u:\public\Web_output\ods_javameta_exp.htm'; goptions reset=all device=javameta border ftext="Helvetica" ftitle="Helvetica"; title1 '1993 Sales'; proc gchart data=prdsummary(where=(year=1993)); hbar3d country / sumvar=actual subgroup=product sum shape=hexagon caxis=black cframe=blue; by quarter; run; quit; title1 '1994 Sales'; proc gchart data=prdsummary(where=(year=1994)); hbar3d country / sumvar=actual subgroup=product sum shape=hexagon caxis=black cframe=blue; by quarter; run; quit; ods html close;

Producing a Web Presentation with the META2HTM Macro

The following sample program uses the META2HTM macro to create an HTML file, and GOPTIONS DEVICE=JAVAMETA with PROC GCHART to create graphical output in the form of metacodes. When you use the META2HTM macro, the metacodes produced by a SAS/GRAPH procedure are embedded in the HTML file. This enables you to display multiple charts with one invocation of the Metaview applet.

The sample codes contains one invocation of PROC GCHART with a BY statement to produce charts for each quarter of the year. However, each of the four charts is displayed in sequence on a single output area of the same HTML page (no scrolling is necessary). The Metaview applet provides a slider control, which allows a user to select which quarter to display.

SAS Code

The following is the complete SAS code to generate a web presentation. You should notice the following:

data prdsummary; input Year Quarter Country . Product . Actual dollar10.2; label Actual = 'Actual Sales'; format Actual dollar11.; datalines; 1993 1 CANADA BED ,337.00 1993 1 CANADA CHAIR ,115.00 1993 1 CANADA DESK ,644.00 1993 1 GERMANY BED ,026.00 1993 1 GERMANY CHAIR ,276.00 ...more data lines... 1994 4 CANADA CHAIR ,166.00 1994 4 CANADA DESK ,662.00 1994 4 GERMANY BED ,026.00 1994 4 GERMANY CHAIR ,246.00 1994 4 GERMANY DESK ,329.00 ; run; /* When goptions device=javameta, the procedure output goes to _webout. */ /* In this case the metacodes are embedded in the html file. */ filename _webout 'u:\public\Web_output\meta2htm_javameta_sample1.htm'; %meta2htm(capture=on, htmlfref=_webout, openmode=replace, /* Specify codebase if metafile.zip is not in same */ /* directory as the html file. */ codebase=http://web_server_name/sasweb/graph archive=metafile.zip, slidectl=n, /* don't advance pictures automatically like a slideshow */ hspace=1, vspace=2); goptions reset=all device=javameta border ftext="Helvetica" ftitle="Helvetica"; title1 '1993 Sales'; proc gchart data=prdsummary(where=(year=1993)); hbar3d country / sumvar=actual subgroup=product sum shape=hexagon caxis=black cframe=blue; by quarter; run; quit; %meta2htm(capture=off, htmlfref=_webout, openmode=append); quit;

Embedding Multiple Instances of the Metaview Applet on the Same HTML Page with META2HTM

Using the META2HTM macro, you can embed multiple instances of the Metaview applet in a single HTML page, and for each instance you can display the output of a different SAS/GRAPH procedure, as illustrated in the current example.

The sample code contains two invocations of PROC GCHART, each invocation with a BY statement, to produce a total of eight charts (four quarters per year times two years ). The Metaview applet is invoked twice, and each time provides a slider control, which enables a user to select which quarter to display for that particular year.

SAS Code

The following is the complete SAS code to generate a Web presentation. You should notice the following:

data prdsummary; input Year Quarter Country . Product . Actual dollar10.2; label Actual = 'Actual Sales'; format Actual dollar11.; datalines; 1993 1 CANADA BED ,337.00 1993 1 CANADA CHAIR ,115.00 1993 1 CANADA DESK ,644.00 1993 1 GERMANY BED ,026.00 1993 2 GERMANY BED ,026.00 ...more data lines... 1994 4 CANADA CHAIR ,166.00 1994 4 CANADA DESK ,662.00 1994 4 GERMANY BED ,026.00 1994 4 GERMANY CHAIR ,246.00 1994 4 GERMANY DESK ,329.00 ; /* When goptions device=javameta, the output of the procedure */ /* goes to _webout. */ /* In this case, the metcodes output is embedded in the html */ /* file produced by meta2htm. */ filename _webout 'u:\public\Web_output\meta2htm_javameta_sample2.htm'; %meta2htm(capture=on, htmlfref=_webout, openmode=replace, /* Specify codebase if metafile.zip is not in same directory as the */ /* html file. */ codebase=http://web_server_name/sasweb/graph archive=metafile.zip, pagepart=head, slidectl=n, /* don't advance pictures automatically like a slideshow */ hspace=1, vspace=2); goptions reset=all device=javameta border ftext="Helvetica" ftitle="Helvetica"; title1 '1993 Sales'; proc gchart data=prdsummary(where=(year=1993)); hbar3d country / sumvar=actual subgroup=product sum shape=hexagon caxis=black cframe=blue; by quarter; run; quit; %meta2htm(capture=off, htmlfref=_webout, openmode=append, pagepart=body); %meta2htm(capture=on, htmlfref=_webout, archive=metafile.zip, openmode=append, slidectl=n, /* don't advance pictures automatically like a slideshow */ pagepart=body); title1 '1994 Sales'; proc gchart data=prdsummary(where=(year=1994)); hbar3d country / sumvar=actual subgroup=product sum shape=hexagon caxis=black cframe=blue; by quarter; run; quit; %meta2htm(capture=off, htmlfref=_webout, openmode=append, pagepart=foot); quit;

Категории