Example 4: Using the Output Delivery System with SAS/CONNECT

Purpose

ODS enables you to format and change the appearance of a procedure's output. The output is converted into objects that can be stored in HTML or in a SAS data set and can be manipulated and viewed in different ways.
This program creates, in a server session, a SAS data set and a SAS view that contain information about U.S. Presidents. The program then generates ODS output. The first half of this example creates HTML from the SAS data set and SAS view. The second half uses ODS to create a SAS data set from the SAS view.

Program

rsubmit;

   data presidnt; 
      length fname lname $8 party $1 lady1 $10;
      input fname lname party year_in lady1;
   datalines;
John Kennedy D 1961 Jackie
Lyndon Johnson D 1963 LadyBird
Richard Nixon R 1969 Pat
Gerald Ford R 1974 Betty
Jimmy Carter D 1977 Rosalynn
Ronald Reagan R 1981 Nancy
George Bush R 1989 Barbara
Bill Clinton D 1993 Hillary
George W Bush R 2002 Laura
   ;
   run;

   proc sql nocheck;
      create view democrat as 
      select fname,lname,party,lady1 
         from presidnt
         where party='D';
   quit;

endrsubmit;

   /* Use ODS to create HTML from the output */

filename rsub "rsub.html" mod;
filename rsubc "rsubc.html" mod;
filename rsubf "rsubf.html" mod;
ods html 
   file=rsub;
   contents=rsubc;
   frame=rsubf;

   /* Remote SQL PassThru to SQL view */
proc sql nocheck;
   connect to remote (server=rmthost);
title 'RSPT: Democrats';
   select fname,lname,lady1 
      from connection to remote 
      (select * from democrat);
quit;

   /* mix remote-submitted SQL with client SQL */
title 'RSPT: Republicans';
rsubmit;
   proc sql nocheck;
     select fname,lname,lady1
        from presidnt 
        where party='R';
quit;
endrsubmit;

ods html close;

   /* Use ODS to create a SAS data set */
ods output output="rdata";

rsubmit;
   proc print data=democrat;
   run;
endrsubmit;
SAS Output Window
SAS Output Window