Example 6. RLS: Subsetting Server Data for Client Processing and Display

Purpose

If the amount of data that is needed for a processing job is small, RLS is an efficient way to gather current data that is on a server for client processing and display. This program subsets the data on the server so that only the data you need is transferred. This method saves computing resources on the server and reduces network traffic while it gives you access to the most current data.
In this example, a large reservations database is located on a server that runs under the UNIX operating environment. Several client procedures need to be run against a small subset of the data that is contained in the master reservations database. This situation is ideal for RLS.
The LIBNAME statement is issued in the client session to define the server library that contains the data set RESERVC. The PROC SORT statement sorts the server data set and writes the subset data to the client disk.
The WHERE= and KEEP= options are specified in the PROC SORT statement to reduce the amount of data that moves through the network to the client session for processing. Only the data that meets the WHERE= and KEEP= criteria is moved across the network to the client session.
PROC SORT creates the subset data set in the client session and allows all subsequent processing to run in the client session without additional server CPU consumption. PROC SUMMARY and PROC REPORT summarize and format the client data. ODS is used to create an HTML file.

Program

1 signon srv1;
       libname remlib '/u/user1/reservations' server=srv1;
2
 proc sort data=
       remlib.reservc(keep=company origin 
       where=(origin='ATLANTA'))
       out=tmp;
       by company;
    run;
3
  proc summary data=tmp 
       vardef=n noprint;
       by company;
       output out=tmp2;
    run;
4
  ods html body="body.htm";
    5
  proc report ls=74 ps=85 split=
    "/" HEADLINE HEADSKIP CENTER NOWD;
    column 
      ("Totals" "" "" "" company _freq_);
    define company / group format=$40. 
       width=40 spacing=2 left "Company";
    define _freq_ / sum width=14 
       spacing=2 right "# Reservations";
    rbreak after /ol dul skip summarize 
       color=cyan;
    run;

    ods html close;
    
1 Executes the LIBNAME statement in the client session to define the server library.
2 PROC SORT runs in the client session but accesses the server data set RESERVC. A subset of RESERVC is written to the client data set TMP. The WHERE= and KEEP= options are passed to the server session and evaluated there to minimize the amount of data that must move across the network.
3 Summarizes the client data set.
4 Creates an HTML file.
5 Creates a report using the client summary data set.