Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referencing a remote SAS work library from another session

Tags:

sas

sas-macro

Ever had a problem with a SAS session, but been unable to close the session due to having critical files in your remote work library (RWORK)??

I certainly have! So how do you access that library from another (new) session?

like image 994
Allan Bowe Avatar asked Dec 28 '25 22:12

Allan Bowe


1 Answers

Here's a macro I wrote to assign a multiple libref to all remote work directories owned by you :

rsubmit ;

%MACRO DOUBLELIB(USER=&SYSUSERID,LIB=double) / des="Assign libname of double for multiple SAS sessions for the same user";

 options nosymbolgen nomprint ;

 %LET WRK     = %SYSFUNC(pathname(work)) ;
 %LET WRKDIR  = %SYSFUNC(scan(&WRK,-1,/)) ;
 %LET SASTEMP = %SYSFUNC(tranwrd(&WRK,&WRKDIR,)) ;

 filename mywork pipe "ls -ls &SASTEMP" ;
 data zwork ;
   infile mywork lrecl=512 recfm=v pad ;
   input @1 char $512. ;
   if index(upcase(char),upcase("&USER")) and ^index(char,scan("&WRK",-1,'/')) and index(char,'SAS_work');
   path = scan(char,-1,' ') ;
   n + 1 ;
   call symput('PATH'||compress(n),"&SASTEMP"||strip(path)) ;
   call symput('PATHN',compress(n)) ;
 run ;

 %NOBS(zwork) ;
 %IF &NOBS > 0 %THEN %DO ;
   libname &LIB (
     %DO I = 1 %TO &PATHN ;
       "&&PATH&I"
     %END ;
   ) access=readonly ;
 %END ;
 options symbolgen mprint ;
%MEND DOUBLELIB;

%DOUBLELIB(LIB=dblwork) ;

endrsubmit ;

/* Assign local libref to new remote dblwork libref */
libname rdouble slibref=dblwork server=myserver ;
like image 194
Chris J Avatar answered Dec 31 '25 17:12

Chris J