ODS Statements in SAS

Last updated on Dec 13 2021
Vaidehi Reddy

Table of Contents

ODS Statements in SAS

The output from a SAS program can be converted to more user friendly forms like .html or PDF. This is done by using the ODS statement available in SAS. ODS stands for output delivery system. It is mostly used to format the output data of a SAS program to nice reports which are good to look at and understand. That also helps sharing the output with other platforms and soft wares. It can also combine the results from multiple PROC statements in one single file.

Syntax

The basic syntax for using the ODS statement in SAS is −

ODS outputtype
PATH path name
FILE = Filename and Path
STYLE = StyleName
;
PROC some proc
;
ODS outputtype CLOSE;

Following is the description of the parameters used −

  • PATH represents the statement used in case of HTML output. In other types of output we include the path in the filename.
  • Style represents one of the in-built styles available in the SAS environment.

Creating HTML Output

We create HTML output using the ODS HTML statement.In the below example we create a html file in our desired path. We apply a style available in the styles library. We can see the output file in the mentioned path and we can download it to save in an environment different from the SAS environment. Please note that we have two proc SQL statements and both their output is captured into a single file.

ODS HTML
PATH = '/folders/myfolders/sasuser.v94/Tecklearn/'
FILE = 'CARS2.html'
STYLE = EGDefault;
proc SQL;

select make, model, invoice
from sashelp.cars
where make in ('Audi','BMW')
and type = 'Sports'
;

quit;

proc SQL;
select make,mean(horsepower)as meanhp
from sashelp.cars
where make in ('Audi','BMW')
group by make;
quit;

ODS HTML CLOSE;

When the above code is executed, we get the following result −

image001 12
HTML

Creating PDF Output

In the below example we create a PDF file in our desired path. We apply a style available in the styles library. We can see the output file in the mentioned path and we can download it to save in an environment different from the SAS environment. Please note that we have two proc SQL statements and both their output is captured into a single file.

ODS PDF

FILE = '/folders/myfolders/sasuser.v94/Tecklearn/CARS2.pdf'

STYLE = EGDefault;

proc SQL;

select make, model, invoice

from sashelp.cars

where make in ('Audi','BMW')

and type = 'Sports'

;

quit;

proc SQL;

select make,mean(horsepower)as meanhp

from sashelp.cars

where make in ('Audi','BMW')

group by make;

quit;

ODS PDF CLOSE;

When the above code is executed we get the following result −

image002 16
PDF

Creating TRF(Word) Output

In the below example we create a RTF file in our desired path. We apply a style available in the styles library. We can see the output file in the mentioned path and we can download it to save in an environment different from the SAS environment. Please note that we have two proc SQL statements and both their output is captured into a single file.

ODS RTF

FILE = '/folders/myfolders/sasuser.v94/Tecklearn/CARS.rtf'

STYLE = EGDefault;

proc SQL;

select make, model, invoice

from sashelp.cars

where make in ('Audi','BMW')

and type = 'Sports'

;

quit;




proc SQL;

select make,mean(horsepower)as meanhp

from sashelp.cars

where make in ('Audi','BMW')

group by make;

quit;


ODS rtf CLOSE;

When the above code is executed we get the following result −

image003 10
TRF(Word)

So, this brings us to the end of blog. This Tecklearn ‘ODS Statements in SAS’ blog helps you with commonly asked questions if you are looking out for a job in SAS. If you wish to learn SAS and build a career in Data Analytics domain, then check out our interactive, SAS Training for SAS BASE Certification Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/sas-training-for-sas-base-certification/

SAS Training for SAS BASE Certification Training

About the Course

SAS Certification Training is intended to make you an expert in SAS programming and Analytics. You will be able to analyse and write SAS code for real problems, learn to use SAS to work with datasets, perform advanced statistical techniques to obtain optimized results with Advanced SAS programming.  In this SAS online training course, you will also learn SAS macros, Machine Learning, PROC SQL, procedure, statistical analysis and decision trees. You will also work on real-life projects and prepare for the SAS Certified Base Programmer certification exam. Upon the completion of this SAS online training, you will have enough proficiency in reading spreadsheets, databases, using SAS functions for manipulating this data and debugging it.

Why Should you take SAS Training?

  • The average salary for a Business Intelligence Developer skilled in SAS is $100k (PayScale salary data)
  • SAS, Google, Facebook, Twitter, Netflix, Accenture & other MNCs worldwide are using SAS for their Data analysis activities and advance their existing systems.
  • SAS is a Leader in 2017 Gartner Magic Quadrant for Data Science Platform.

What you will Learn in this Course?

Introduction to SAS 

  • Introduction to SAS
  • Installation of SAS
  • SAS windows
  • Working with data sets
  • Walk through of SAS windows like output, search, editor etc

SAS Enterprise Guide

  • How to read and subset the data sets
  • SET Statement
  • Infile and Infile Options
  • SAS Format -Format Vs Informat

SAS Operators and Functions

  • Using Variables
  • Defining and using KEEP and DROP statements
  • Output Statement
  • Retain Statement
  • SUM Statement

Advanced SAS Procedures

  • PROC Import
  • PROC Print
  • Data Step Vs Proc
  • Deep Dive into Proc

Customizing Datasets

  • SAS Arrays
  • Useful SAS Functions
  • PUT/INPUT Functions
  • Date/Time Functions
  • Numeric Functions
  • Character Functions

SAS Format and SAS Graphs

  • SAS Format statements
  • Understanding PROC GCHART, various graphs, bar charts: pie, bar

Sorting Techniques

  • NODUP
  • NODUKEY
  • NODUP Vs NODUKEY

Data Transformation Function

  • Character functions, numeric functions and converting variable type
  • Use functions in data transformation

Deep Dive into SAS Procedures, Functions and Statements

  • Find Function
  • Scan Function
  • MERGE Statement
  • BY Statement
  • Joins
  • Procedures Vs Function
  • Where Vs If
  • What is Missover
  • NMISS
  • CMISS

PROC SQL

  • SELECT statement
  • Sorting of Data
  • CASE expression
  • Other SELECT statement clauses
  • JOINS and UNIONS

Using SAS Macros

  • Benefits of SAS Macros
  • Macro Variables
  • Macro Code Constituents and Macro Step
  • Positional Parameters to Macros

Got a question for us? Please mention it in the comments section and we will get back to you.

0 responses on "ODS Statements in SAS"

Leave a Message

Your email address will not be published. Required fields are marked *