Published on :
Reporting SASHELP

ODS Style Examples Generation

This code is also available in: Deutsch Español Français
This script retrieves the list of all available ODS styles via the TEMPLATE procedure by redirecting the output to a temporary catalog. It then iterates through this list using a DATA step and uses CALL EXECUTE to dynamically generate an HTML report (based on PROC MEANS and sashelp.class) for each identified style. Note: The output path is configured for a Windows environment ('c:\ODS_test\').
Data Analysis

Type : SASHELP


Uses the 'sashelp.class' table for report generation and internal SAS metadata (PROC TEMPLATE) for the list of styles.

1 Code Block
DATA STEP
Explanation :
Specific command for the 'Display Manager' interface (PC SAS) to clear logs and output. Can be ignored or generate an error under SAS Viya/Studio depending on the configuration.
Copied!
1dm 'log; clear; output; clear';
2 Code Block
PROC PRINTTO
Explanation :
Defines a temporary catalog as the file destination. Redirects standard output (PRINT) to this catalog, executes PROC TEMPLATE to list styles (which writes the list to the catalog), then restores standard output.
Copied!
1filename list catalog 'work.temp.temp.source' ;
2 
3PROC PRINTTO PRINT=list new ;
4RUN;
5 
6ODS listing;
7 
8PROC TEMPLATE ;
9 list styles ;
10RUN ;
11 
12ODS listing close;
13 
14PROC PRINTTO ;
15RUN;
3 Code Block
DATA STEP
Explanation :
Reads the file containing the list of styles. For each style found, uses CALL EXECUTE to dynamically generate and execute SAS code that: 1) Opens an ODS HTML destination with the specified style, 2) Executes a PROC MEANS on sashelp.class, 3) Closes the ODS destination.
Copied!
1DATA _null_ ;
2 LENGTH style $ 17 ;
3 INFILE list missover ;
4 INPUT @'Styles.' style ;
5 IF style>' ' ;
6
7 * create a folder for the files, then change the drive/folder below;
8 
9 call execute('ods html file="c:\ODS_test\'||strip(style)||'.html" style='||style||';') ;
10 call execute('title "'||style||'";') ;
11 call execute('proc means data=sashelp.class maxdec=2; run ;') ;
12 call execute('ods html close'||';') ;
13RUN ;
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.
Copyright Info : modified by Elizabeth A. Swoope, Louisiana State University