SAS Workshop Introduction to SAS Programming Iowa State University

advertisement
SAS Workshop
Introduction to SAS
Programming
DAY 2 SESSION III
Iowa State University
May 10, 2016
Current SAS Software Products












Base SAS
Base SAS Procedures
Base SAS Statistical Procedures
ODS Graphics Procedures (now in Base SAS)
SAS/STAT
SAS Enterprise Guide
SAS Enterprise Miner
SAS/GRAPH
SAS/ETS
SAS/QC
SAS/IML
SAS Forecast Server
Output Delivery System (ODS)
 ODS allows flexibility in presenting output from SAS





procedures
It also can create output in a variety of formats, such as: html,
pdf, rtf, etc. (called destinations)
Traditionally, results of a SAS procedure were displayed in a the
output window in the listing format.
As output from SAS procedures, ODS creates output objects
that have basically three components: data component, table
definition (order of columns, rows, etc.), and an output destination
(.html, .rtf, etc.)
ODS can arrange output in more presentable ways using
customization.
Some SAS Procedures also produce ODS Graphical output
ODS (continued)
Examples of currently available ODS destinations:
 LISTING: produces traditional SAS monospace typeset output
 PS or PDF: output that is formatted for a high-resolution printer such as
PostScript or PDF
 HTML: output that is formatted in various markup languages such
as HTML
 RTF: output that is formatted for use with Microsoft Word
Templates:
ODS provides table templates that define the structure of the
output from SAS procedures.You can customize the output by
modifying these templates, or by creating your own using PROC
TEMPLATE
Current Default Settings in SAS 9.4
 The default destination in the SAS windowing environment is html






(changed from traditional listing destination)
In the past, SAS users used SAS/Graph (and many other procedures) to
produce high quality graphics. We’ll call these traditional SAS graphics.
Template-based graphics produced by ODS Graphics (different from
traditional SAS graphics) is now used for producing graphs in most SAS
procedures. ODS Graphics is enabled by default at SAS start-up.
Previously, in the SAS Windowing environment, ODS GRAPHICS ON
statement was used to enable ODS Graphics (and ODS GRAPHICS OFF
statement to disable ODS Graphics). Do not need this anymore.
Now ODS GRAPHICS ON is the default. The default style for the
HTML destination is HTMLBlue
This new style is an all-color style that is designed to integrate tables and
modern statistical graphics, viewable as a single entity.
Use the Results tab in the Preferences window to change to the destination
to listing or to choose a different style.
Sample SAS Program C1
The following SAS program accesses the SAS dataset named biology,
carries out a distribution analysis using proc univariate, and delivers
the output to an rtf destination.
libname libc "U:\Documents\SAS_Workshop_Spring2016\Data\";
ods rtf file="U:\Documents\SAS_Workshop_Spring2016\c1_out.rtf";
proc univariate data=libc.biology Normal;
var Height;
title "Biology class: Analysis of Height Distribution";
run;
ods rtf close;
Selecting ODS Tables for Display
 You can use the ODS SELECT statement to deliver only a subset of





the tables or graphs to ODS destinations.
The ODS SELECT statement selects only specified tables for display
in the ODS destinations.
For example, in a proc reg step: ods select ParameterEstimates;
selects the table of parameter estimates for output.
Each output table and graph from a SAS procedure has an associated
name and label.
You can obtain table names from the individual procedure’s
documentation chapter or from the individual procedure section of
the SAS online Help system
You can also use the SAS Results window (from the SAS Explorer) to
view the names of the tables that are created in your SAS session
Sample SAS Program C2
In this modified version of the previous SAS program, we select
pieces of the output produced to be sent to the rtf destination using
ODS Select.
libname libc "U:\Documents\SAS_Workshop_Spring2016\Data\";
ods rtf file="U:\Documents\SAS_Workshop_Spring2016\c2_out.rtf";
ods select BasicMeasures Quantiles TestsForNormality Histogram ;
proc univariate data=libc.biology Normal;
var Height;
histogram Height/midpoints=60 to 78 by 3 normal;
title "Biology class: Analysis of Height Distribution";
run;
ods rtf close;
Sample SAS Program C3
In this modified version of SAS Program B12, we select pieces of the output produced to be
sent to the pdf destination using ODS Select. Make sure the requested graphics are drawn
using the plots= option.
data muscle;
input x y;
label x='Age' y='Muscle Mass';
datalines;
71
82
64
91
43
100
. . . . . . .
. . . . . . .
53
100
49
105
78
77
;
*ods pdf file="U:\Documents\SAS_Workshop_Spring2016\c3_out.rtf";
ods select ANOVA ParameterEstimates ResidualByPredicted FitPlot QQPlot;
proc reg data=muscle plots=all;
model y = x/r p;
title 'Simple Linear Regression Analysis of Muscle Mass Data';
run;
*ods pdf close;
Download