Sample Programs for Static Images


The following sample programs create a Web presentation with a static image:

  • Using ODS with the ACTXIMG Device Driver on page 447

  • Generating GIF Output Using ODS on page 450

  • GIF Output with Hotspot Links on page 452

Using ODS with the ACTXIMG Device Driver

The following sample program uses ODS HTML to create an HTML file that references four PNG files created by a SAS procedure when DEVICE=ACTXIMG. Because the ACTXIMG device driver invokes an ActiveX Control, you can only run this example in a Windows environment.

The GCHART procedure in this example includes a BY statement to display the results of each of the four quarters of the year. Consequently, the procedure produces four separate PNG files, only the first of which is shown here. A user would have to scroll down the page in the browser to see all the PNG images displayed.

click to expand
Display 13.3: Using ODS with the ACTXIMG Device Driver

The following is the complete SAS code to generate PNG files from a SAS/GRAPH procedure using GOPTIONS DEVICE=ACTXIMG. You should notice the following:

  • PROC GREPLAY is used to delete any old GRSEGs that were created. This is not necessary, but otherwise SAS creates new GRSEGs each time the procedure is run rather than replacing the old, and from them creates new PNG files, incrementing the suffix number for each new PNG file.

  • The FILE= option of the ODS HTML statement specifies the path and filename of the HTML file to be created. If you want to run this example, then change the value of the option to the location where you want to store the file.

    Note: You can specify the complete path and filename with the FILE= option (or the BODY= option, which is the same), or you can specify the path separately using the PATH= option, and just the filename with the FILE= or BODY= option. See the section ODS HTML Statement in the SAS Output Delivery System: User s Guide .

  • The GPATH= option of the ODS HTML statement specifies the directory where the PNG files are to be created. If you want to run this example, then change the value of the option to the location where you want to store the file.

  • Specifying that GOPTIONS DEVICE=ACTXIMG causes the GCHART procedure to produce PNG output.

 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 grsegs before creating new ones */  proc greplay igout=work.gseg nofs;     delete _all_;     /* could also specify: delete _1993, _19931, etc. */  run;  quit;  ods listing close;   /* gpath specifies the directory where PNGs are created */  ods html file='u:\public_html\Web_output\ods_actximg.htm'      gpath='u:\public_html\Web_output\'      style=torn;  goptions reset=all device=actximg;  title1 '1993 Sales';  proc gchart data=prdsummary(where=(year=1993));     hbar3d country / sumvar=actual subgroup=product sum     shape=hexagon caxis=black cframe=CXb0c1f4 name='_1993';     by quarter;  run;  quit;  ods html close;  ods listing; 

Generating GIF Output Using ODS

The following sample program uses ODS to create an HTML file that references four GIF files created by a SAS procedure when DEVICE=GIF. The GIFs are displayed one after the other in the HTML page, so that a user would have to scroll to see all the graphs.

The GCHART procedure in this example includes a BY statement to display the results of each of the four quarters of the year. Consequently, the procedure produces four separate GIF files, only the first of which is shown here. A user would have to scroll the page in the browser to see all the GIF images displayed.

click to expand
Display 13.4: Generating GIF Output Using ODS

The following is the complete SAS code to generate GIF files from a SAS/GRAPH procedure. You should notice the following:

  • PROC GREPLAY is used to delete the GRSEGs that are already created. This is not necessary, but otherwise SAS creates new GRSEGs each time the procedure is run, rather than overwriting the old, and from the new GRSEGs creates new GIF files, incrementing the suffix number for each new GIF.

  • The FILE= option of the ODS HTML statement specifies the path and filename of the HTML file to be created. If you want to run this example, then change the value to the directory where you want to store the HTML file.

    Note: You can specify the complete path and filename with FILE= (or BODY=, which is a synonym), or you can specify the path separately using PATH=, and just the filename with FILE= (or BODY=) See the SAS Output Delivery System: User s Guide for information on the ODS HTML statement.

  • The GPATH= option of the ODS HTML statement specifies the directory where the GIF files are to be created. If you want to run this example, then change the value of the option to the location where you want to store the file.

  • The statement GOPTIONS DEVICE=GIF causes the GCHART procedure to produce GIF output.

 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 2 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  ;   /* delete previously created grsegs before creating new ones */  proc greplay igout=work.gseg nofs;     delete _all_;  run;  quit;  ods listing close;   /* "file=" specifies the html file to be created                        */   /* Change the value of file= to the directory where you want            */   /* to store the HTML file                                               */   /* Change file= to the directory where you want to store the HTML file  */   /* "gpath=" specifies the directory where GIFs are created              */   /* Change the value of gpath= to the directory that you are using       */  ods html file='u:\public_html\Web_output\ods_gif.htm'           gpath='u:\public_html\Web_output\';  goptions reset=all device=gif           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=CXb0c1f4 name='1993_';     by quarter;  run;  quit;  ods html close;  ods listing; 

GIF Output with Hotspot Links

This example shows you how to generate Web output with drill-down functionality using the GIF device driver (see also Generating Drill-Down Web Presentations with the GIF, JPEG, or PNG Device Driver on page 447).

In the program, the DEVICE=GIF specification generates image output files and the ODS HTML statement generates an HTML output file. The HTML= option identifies a link variable that provides drill-down URLs. The values of the link variables are added to the data set with IF/THEN statements. ODS inserts the drill-down URLs into an image map that it generates in the HTML output file.

When you display the HTML output file in a Web browser and select one of the three blocks in the chart, you see a table of the data for that block.

click to expand
Display 13.5: Three-Dimensional Vertical Bar Chart with Drill-Down Links

Here is the example code, which is available in the SAS Sample Library under the name GWBDRILL:

 /* Close the listing destination */  ods listing close;  /* Set graphic options. */  goptions reset=global gunit=pct           transparency noborder           htitle=6 htext=3           device=gif;  /* Create the data set REGSALES. */  data regsales;     length Region State $ 8;     format Sales dollar8.;     input Region State Sales;  /* Initialize the link variable. */     length rpt ;  /* Assign values to the link variable. */  if Region='Central' then       rpt='href="central.html"';     else if Region='South' then       rpt='href="south.html"';     else if Region='West' then       rpt='href="west.html"';     datalines;  West CA 13636  West OR 18988  West WA 14523  Central IL 18038  Central IN 13611  Central OH 11084  Central MI 19660  South FL 14541  South GA 19022  ;  /* Remove the comments below to open the HTML destination for ODS output. */  /* Specify the filename in BODY= and the output path in PATH=.            */  /* ods html body='your-filename.htm'      path='your-web-path';           */  /* Create a chart that uses the link variable. */  title1 'Company Sales';  proc gchart data=regsales;     vbar3d region / sumvar=sales     patternid=midpoint     html=rpt;  run;  quit;  /* Remove the comments below, and specify the filename and */  /* path to open an HTML file that will contain the report. */  /* ods html body='your-filename.htm' */  /* path='your-web-path';             */  title1 'Central Sales';  proc print data=regsales noobs;     var state sales;     where region='Central';  run;  quit;  title1 'Southern Sales';  /* Remove the comments below, and specify the filename and */  /* path to open an HTML file that will contain the report. */  /* ods html body='your-filename2.htm' */  /*     path='your-web-path';          */  proc print data=regsales noobs;     var state sales;     where region='South';  run;  quit;  title1 'Western Sales';  /* Remove the comments below, and specify the filename and */  /* path to open an HTML file that will contain the report. */  /* ods html body='your-filename3.htm' */  /* path='your-web-path';              */;  proc print data=regsales noobs;     var state sales;     where region='West';  run;  quit;  /* Close the HTML output file and */  /* open the listing destination.  */  ods html close;  ods listing; 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net