views:

287

answers:

3

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?

+2  A: 

not sure of the ethics of asking a question you know the answer to, but hopefully others will find this useful!

%macro serverpath;
%put NOTE:; %put NOTE-; %put NOTE-; 
%put NOTE- libname OldWork "%sysfunc(pathname(RWORK))" server= remote %str(;);
%put NOTE- rsubmit%str(;);
%put NOTE- libname OldWork "%sysfunc(pathname(RWORK))"%str(;);
%mend; %serverpath;

This will put the code you need in the log. The bit you may need to change is the server= option - this should be the name of the environment you have logged onto (not sure how to reference this programmatically - does anyone else know?)

Obviously the original session needs to remain open (to prevent RWORK from being wiped) and the second session needs to be logged onto the same server...

Bazil
Totally ethical. Anything to get SAS-related content populated into SO.
Jay Stevens
+2  A: 
Chris J
Thanks Chris - worked perfectly! have added a %nobs macro in a separate answer for those who don't hav one...
Bazil
question - how do you avoid having to change the "server=myserver" bit???
Bazil
+2  A: 

response to Chris J's response - missing macro..

rsubmit ;
%macro nobs(dsn);
%local dsnid rc;
%global nobs;
%let nobs=.;
%* open the data set of interest ;
%let dsnid=%sysfunc(open(&dsn));
%* If the open was successful get the nobs and CLOSE &dsn ;
%if &dsnid %then %do;
    %let nobs=%sysfunc(attrn(&dsnid,nlobs)); 
    %let rc =%sysfunc(close(&dsnid));
%end; %else %do; 
    %put WARNING:  Unable to open &dsn - %sysfunc(sysmsg());
    %let nobs=0;
%end;  %mend nobs;
endrsubmit;
Bazil