www.sas.com > Service and Support > Technical Support
 
Technical Support SAS - The power to know(tm)
  TS Home | Intro to Services | News and Info | Contact TS | Site Map | FAQ | Feedback



/**********************************************************************/
/* This program creates HTML and GIF files in version 6.12 that mimic */
/* the format created by the WEBFRAME device first available in       */
/* version 7 of the SAS system.  It assumes you want to display all   */
/* the graphs stored in the specified catalog.  It will create a      */
/* parent page, PFRAME.HTML, that displays two smaller frames.  The   */
/* left frame, THUMB.HTML, will contain a list of all the graphs,     */
/* including a thumbnail image and a text link for each.  Selecting   */
/* one of these links will display the larger GIF image of the same   */
/* graph in the right frame.  Initially, the first graph in the       */
/* catalog is displayed in the right frame.                           */
/*                                                                    */
/* As with the WEBFRAME driver, the parent frame and index frame are  */
/* named automatically. Unlike the WEBFRAME driver, the images and    */
/* links on these pages are not automatically given the GRSEG names   */
/* of the graphs.  Use the NAME parameter when invoking the macro to  */
/* name the links on the list page, the large GIF files, and the      */
/* displayed HTML files.  The directory you specify to store the      */
/* files must already exist; SAS will not create the directory for    */
/* you.                                                               */
/**********************************************************************/

/**********************************************************************/
/* Uncomment this statement to troubleshoot the macro.                */
/**********************************************************************/
*options mprint mlogic symbolgen;

/**********************************************************************/
/* Clear the catalog and make some sample graphs.  This example uses  */
/* the catalog WORK.TEMP.                                             */
/**********************************************************************/
proc greplay igout=work.temp nofs;delete _all_;run;quit;
goptions reset=all dev=gif ftext=centx htext=2;

data sample;
  do x=-3 to 3 by .1;
    y=sin(x);
    output;
  end;

title1 'SIN of X';
symbol1 i=spline c=blue;
proc gplot data=sample gout=work.temp;
plot y*x;
run;quit;

title1 'HBAR of X';
pattern1 v=s c=green;
proc gchart data=sample gout=work.temp;
hbar x / sumvar=y;
run;quit;

/**********************************************************************/
/* Define the macro FRAME.                                            */
/* LIBRARY:  The library where the graphs are stored.                 */
/* CATALOG:  The catalog where the graphs are stored.                 */
/* PATH:     The physical location (drive & directory) where you want */
/*           to store the output files.                               */
/* NAME:     The name of the output files.                            */
/* HSIZE:    The HSIZE to use to generate the large GIF files.        */
/* VSIZE:    The VSIZE to use to generate the large GIF files.        */
/*                                                                    */
/* The macro does not contain parameters to name the parent frame or  */
/* the list frame.  These frames are named PFRAME.HTML and THUMB.HTML */
/* by default, but these names can be changed within the macro before */
/* compiling if desired.                                              */
/**********************************************************************/
%macro frame(library,catalog,path,name,hsize,vsize);

/**********************************************************************/
/* Find the number of graphs in the catalog.  Save this count         */
/* as TOTAL.                                                          */
/**********************************************************************/
data one;
  rc=gset('catalog',"&library","&catalog");
  rc=ginit();
  call gask('numgraph',grsegcnt,rc);
  call symput('total',grsegcnt);
  rc=gterm();
run;

/**********************************************************************/
/* Make the large GIFs, the thumbnails, and the html pages for the    */
/* graphs.                                                            */
/**********************************************************************/
%do i=1 %to &total;
  filename out "&path\&name&i..gif";
  goptions dev=gif gsfname=out gsfmode=replace hsize=&hsize vsize=&vsize;
  proc greplay igout=&library..&catalog nofs;
    replay &i;
  run;quit;

  goptions hsize=.5 vsize=.5;
  filename out "&path\small&i..gif";
  proc greplay igout=&library..&catalog nofs;
    replay &i;
  run;quit;

  filename page "&path\&name&i..html";
  data _null_;
    file page;
    put '<HTML>';
    put '<P ALIGN=CENTER><IMG SRC="' @@;
    put "&name&i..gif" @@;
    put '"></P>';
    put '/HTML>';
  run;
%end;

/**********************************************************************/
/* Create the parent frame, PFRAME.HTML.  The left frame will be 15%  */
/* of the initial browser window size.                                */
/**********************************************************************/
filename parent "&path\pframe.html";
data _null_;
  file parent;
  put '<HTML><HEAD><TITLE>SAMPLE: </TITLE><TITLE>SAS\Graph</TITLE></HEAD>';
  put '<FRAMESET COLS="15%,*">';
  put '<NOFRAMES>';
  put 'Sorry, this frame output can only be viewed with a' @@;
  put ' frame capable browser like Netscape 2.0 and above.';
  put '</NOFRAMES>';
  put '<FRAME SRC="thumb.html">';
  put '<FRAME SRC="' @@;
  put "&name.1.html" @@;
  put '" NAME="view_frame">';
  put '</FRAMESET>';
  put '</HTML>';
run;

/**********************************************************************/
/* Create the thumbnail page, THUMB.HTML.                             */
/**********************************************************************/
filename list "&path\thumb.html";
data _null_;
 set one;
  file list;
  put '<HTML>';
  put '<BASE TARGET=view_frame>';
  %do i=1 %to &total;
    put '<P ALIGN=CENTER>';
    put '<A HREF="' @@;
    put "&name&i..html" @@;
    put '"><IMG SRC="' @@;
    put "small&i..gif" @@;
    put '"><BR>';
    put "&name&i" @@;
    put '</A></P>';
  %end;
  put '</HTML>';
run;

%mend;

/**********************************************************************/
/* Invoke the macro using the example graphs and write the output to  */
/* the C:\TEST directory.  The graphs are named MYGRAPH, and the      */
/* large GIF files will be four inches by four inches.                */
/**********************************************************************/
%frame(work,temp,c:\test,MyGraph,4,4);
Copyright (c) 2002 SAS Institute Inc. All Rights Reserved.
Terms of Use & Legal Information | Privacy Statement