Monday, October 24, 2016

Hack 3.24 Taking Advantage of the INHERITLIB Option with SAS/CONNECT

SAS Programming Professionals,

Did you know that when using SAS/CONNECT, you can have a program running on a server “reach back” and process data directly from a SAS data set on your client machine (workstation)? 

The aptly-named INHERITLIB option allows a remotely-running SAS program to process data from your workstation or network as if it were local to the remote server.  Using the INHERITLIB option obviates the need for you to use PROC UPLOAD to send your data to the remote server for processing.  This can be very handy when you do not want to have multiple copies of a data set spread across your various computing platforms.

The INHERITLIB option can be coded on either the RSUBMIT or the SIGNON statement.  Here is an example:

libname pclib "C:\PRODDATA";

rsubmit inheritlib=(pclib);

proc summary nway data=pclib.shoeaud(where=(region="Canada"));

      class region product subsidiary;

      var   sales  returns;

output out=sumshoes sum=;

run

endrsubmit;

run;

In this example, we are allocating the “C:\proddata” directory (on a Windows workstation) to the “PCLIB” libref in our local SAS session.  Thereafter, we RSUBMIT a simple PROC SUMMARY that will run on our Linux server.  The RSUBMIT statement specifies that the remote session is to “inherit” the PCLIB libref.  So, when the SUMMARY procedure executes on the remote Linux server, it “reaches back” to the workstation and drags the relevant observations across the network to the waiting SUMMARY procedure running on the Linux server.  Pretty neat, eh?

Of course, you need to weigh the additional network traffic associated with remote servers processing local data against any gains realized by using the INHERITLIB option.  But, you already knew that; didn’t you?

Best of luck in all your SAS endeavors!

----MMMMIIIIKKKKEEEE
(aka Michael A. Raithel)

Excerpt from the book:  Did You Know That?  Essential Hacks for Clever SAS Programmers

I plan to post each and every one of the hacks in the book to social media on a weekly basis.  Please pass them along to colleagues who you know would benefit.

No comments:

Post a Comment