May 27, 2021 SAS
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.
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:
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:
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:
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: