title: Using namedpipes to transfer ods output and datasets
body: <p>I'm trying to figure out how to use SAS namedpipes to exchange data in SAS processes.  Here is a simple example:</p>
  
  <p>Server</p>
  
  <pre><code>FILENAME stdout namepipe '\\.\pipe\Sas\PipeOut' server eofconnect retry=15 block;
  FILENAME DIRLIST pipe 'dir "C:\atemp"';
  data dirlist ;
      length buffer $256;
      infile dirlist length=reclen;
      input buffer $varying256. reclen;
      *file stdout;
      *put buffer;
  ods listing file=stdout;
  proc print data=dirlist;
  run;
  </code></pre>
  
  <p>Client</p>
  
  <pre><code>FILENAME stdin  namepipe '\\.\pipe\Sas\PipeOut'  client eofconnect retry=15 block;
  data d1;
      length buffer $ 256;
      infile stdin length=reclen;
      input buffer $varying256. reclen;
      put buffer;
  run;
  </code></pre>
  
  <p>If in the server code I uncomment out the file and put statement and remove the ods and proc print, everything pretty much works as expected.  The code as it stands produces results I didn't expect.  I run the server code, then start the client code.  The client code runs but reads zero observations, if I then rerun the client code (before the server times out) it will then read the 60 or so expected lines, then hangs (never terminates).  My best guess is that the ods listing statement closes the file, then reopens it (and never closes it?).  Does anyone know what's going on and how to get the ods output in the client on the first execution, with no hang?</p>
  
  <p>Something else I'd like to do is output the data set on the server to the pipe and using it as a dataset reference in client.  Generally this is done using a library reference and I don't know if or how I can make the pipe file reference appear to be a library reference.  Hope that last part makes sense.  </p>