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.
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.
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/Howcodex/' 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 −
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/Howcodex/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 −
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/Howcodex/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 −