Published on :
Reporting SASHELP

Example 4 - SAS and HTML Output Streaming

This code is also available in: Deutsch Español Français
This script illustrates the technique for mixing raw HTML content (written via DATA steps) and standard SAS© reports (via ODS HTML). It is designed to run in a web context (like SAS© Job Execution), writing the HTML header, then a PROC PRINT report on the SASHELP.CARS table, and finally an HTML footer with a button.
Data Analysis

Type : SASHELP


Uses the standard SASHELP.CARS table.

1 Code Block
DATA STEP
Explanation :
Writes the beginning of the HTML page (header and title) directly to the web output stream (_webout).
Copied!
1DATA _null_;
2 FORMAT INFILE $char256.;
3 INPUT;
4 INFILE = resolve(_infile_);
5 file _webout;
6 put INFILE;
7 cards4;
8
9
10
11
12

13

SAS PROC PRINT OF SASHELP.CARS

14
15
16
17
18;;;;
19RUN;
2 Code Block
ODS HTML
Explanation :
Activates the ODS HTML destination to _webout to include the standard PROC PRINT output (first 10 observations of SASHELP.CARS), then closes the destination to regain manual control of the stream.
Copied!
1ods html file=_webout; /* This line opens the Output Delivery System to allow SAS Proc output streaming and close HTML */
2 
3options nodate nonumber;
4 
5PROC PRINT DATA=sashelp.cars (obs=10);
6RUN;
7 
8 
9ods html close; /* This line closes the Output Delivery System to end SAS Proc output streaming and resume HTML */
3 Code Block
DATA STEP
Explanation :
Writes the continuation and end of the HTML code (button and closing tags) to the web output stream.
Copied!
1DATA _null_;
2 FORMAT INFILE $char256.;
3 INPUT;
4 INFILE = resolve(_infile_);
5 file _webout;
6 put INFILE;
7 cards4;
8
9
10
11
12

13
14
15
16
17
18;;;;
19RUN;
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.