Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

SAS ODS


May 27, 2021 SAS


Table of contents


The output of the SAS program can be converted to more user-friendly forms, such .html or PDF. T his is done by using the ODS statements provided in SAS. O DS represents the output delivery system. I t is mainly used to format the output data of the SAS program to a good report, which is very good to see and understand. T his also helps to share output with other platforms and software. I t can also combine the results of multiple PROC statements in one file.

Grammar

The basic syntax for using ODS statements in SAS is:

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

The following is a description of the parameters used:

  • PATH represents the statement used in the case of HTML output. In other types of output, we include paths in the file name.
  • STYLE represents one of the built-in styles available in the SAS environment.

Create an HTML output

We use ODS HTML statements to create HTML output. I n the following example, we create an html file in the desired path. W e apply the styles provided in the Style Gallery. W e can see the output file in the path mentioned, and we can download it to save it in an environment different from the SAS environment. N ote that we have two proc SQL statements, and their output is captured in a 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 we execute the code above, we get the following results:

SAS ODS

Create a PDF output

In the following example, we create a PDF file in the desired path. W e apply the styles provided in the Style Gallery. W e can see the output file in the path mentioned, and we can download it to save it in an environment different from the SAS environment. N ote that we have two proc SQL statements, and their output is captured in a 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 we execute the code above, we get the following results:

SAS ODS

Create a TRF output

In the following example, we create an RTF file in the desired path. W e apply the styles provided in the Style Gallery. W e can see the output file in the path mentioned, and we can download it to save it in an environment different from the SAS environment. N ote that we have two proc SQL statements, and their output is captured in a 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 we execute the code above, we get the following results:

SAS ODS