- SAS Tutorial
- SAS - Home
- SAS - Overview
- SAS - Environment
- SAS - User Interface
- SAS - Program Structure
- SAS - Basic Syntax
- SAS - Data Sets
- SAS - Variables
- SAS - Strings
- SAS - Arrays
- SAS - Numeric Formats
- SAS - Operators
- SAS - Loops
- SAS - Decision Making
- SAS - Functions
- SAS - Input Methods
- SAS - Macros
- SAS - Dates & Times
- SAS Data Set Operations
- SAS - Read Raw Data
- SAS - Write Data Sets
- SAS - Concatenate Data Sets
- SAS - Merging Data Sets
- SAS - Subsetting Data Sets
- SAS - Sort Data Sets
- SAS - Format Data Sets
- SAS - SQL
- SAS - Output Delivery System
- SAS - Simulations
- SAS Data Representation
- SAS - Histograms
- SAS - Bar Charts
- SAS - Pie Charts
- SAS - Scatterplots
- SAS - Boxplots
- SAS Basic Statistical Procedure
- SAS - Arithmetic Mean
- SAS - Standard Deviation
- SAS - Frequency Distributions
- SAS - Cross Tabulations
- SAS - T Tests
- SAS - Correlation Analysis
- SAS - Linear Regression
- SAS - Bland-Altman Analysis
- SAS - Chi-Square
- SAS - Fishers Exact Tests
- SAS - Repeated Measure Analysis
- SAS - One-Way Anova
- SAS - Hypothesis Testing
- SAS Useful Resources
- SAS - Quick Guide
- SAS - Useful Resources
- SAS - Questions and Answers
- SAS - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
SAS - ODS
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/TutorialsPoint/' 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 −
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/TutorialsPoint/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 −
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/TutorialsPoint/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 −