Web pages frequently contain embedded
graphic images. For static images, an <IMG> tag is enough to
embed the image, as shown in the following example:
<IMG SRC="mykids.gif">
Dynamically generated
images, such as charts that vary over time or due to input parameters,
are more complicated. Stored processes can generate graphics in addition
to HTML output. The following stored process creates a bar chart followed
by a tabular report:
/* Sales by Region and Product */
%stpbegin;
title "Sales by Region and Product";
legend1 label=none frame;
proc gchart data=sashelp.shoes;
hbar3d region / sumvar=sales
sum space=.6
subgroup=product
shape=cylinder
patternid=subgroup
legend=legend1;
label product='Shoe Style';
run;
proc report data=sashelp.shoes;
column region product sales;
define region / group;
define product / group;
define sales / analysis sum;
break after region / ol summarize suppress skip;
run;
%stpend;
Depending on input parameters,
this stored process might produce the following output:
Web Page with Embedded Graphic
No special code was
added to handle the image. ODS and the stored process framework takes
care of the details of delivering both the HTML and the image to the
Web browser. This code handles different image types through the _GOPT_DEVICE
input parameter that is supported by the %STPBEGIN macro.
For more
information, see Using the %STPBEGIN and %STPEND Macros. The image is delivered to the Web
browser in different ways depending on the graphics device. JAVA and
ACTIVEX images are generated by embedding an <OBJECT> tag in
the generated HTML that contains the attributes and parameters necessary
to invoke the viewer and to display the graphic. There is no <IMG>
tag in this case. Other commonly used drivers (GIF, JPEG, PNG, ACTXIMG,
and JAVAIMG) do use the <IMG> tag. The following code is an
HTML fragment that is generated by the previous stored process using
the GIF image driver:
<IMG SRC="/SASStoredProcess/do?_sessionid=
7CF645EB-6E23-4853-8042-BBEA7F866B55
&_program=replay&entry=
STPWORK.TCAT0001.GCHART.GIF">
The image URL in the
<IMG> tag is actually a reference to the SAS Stored Process
Web Application that uses the special stored process named REPLAY.
The REPLAY stored process takes two parameters, _SESSIONID and ENTRY.
_SESSIONID is new, unique value each time the original stored process
is executed. ENTRY is the name of a temporary SAS catalog entry that
contains the generated image. Image replay uses a special, lightweight
version of the stored process sessions feature to hold image files
temporarily until the Web browser retrieves them.
For more information,
see Using Sessions.
You can use the REPLAY
stored process to replay entries other than embedded images, such
as CSS style sheets, JavaScript include files, PDF files, and HTML
or XML files to be displayed in a pop-up window, frame or <IFRAME>.
The special macro variable _TMPCAT contains the name of the temporary
catalog that is used for REPLAY entries. The variable _REPLAY contains
the complete URL that is used to reference the REPLAY stored process
(except the actual entry name). The _TMPCAT catalog remains on the
server for only a limited time. If the catalog is not accessed within
a time-out period (typically 15 minutes), then the catalog and its
contents are deleted.