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!
dm 'log; clear; output; clear';
1
dm '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!
filename list catalog 'work.temp.temp.source' ;
proc printto print=list new ;
run;
ODS listing;
proc template ;
list styles ;
run ;
ODS listing close;
proc printto ;
run;
1
filename list catalog 'work.temp.temp.source' ;
2
3
PROC PRINTTOPRINT=list new ;
4
RUN;
5
6
ODS listing;
7
8
PROC TEMPLATE ;
9
list styles ;
10
RUN ;
11
12
ODS listing close;
13
14
PROC PRINTTO ;
15
RUN;
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!
data _null_ ;
length style $ 17 ;
infile list missover ;
input @'Styles.' style ;
if style>' ' ;
* create a folder for the files, then change the drive/folder below;
call execute('ods html file="c:\ODS_test\'||strip(style)||'.html" style='||style||';') ;
call execute('title "'||style||'";') ;
call execute('proc means data=sashelp.class maxdec=2; run ;') ;
call execute('ods html close'||';') ;
run ;
1
DATA _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'||';') ;
13
RUN ;
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
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.