How can I assign libname to WORK Data Library in SAS?

11k views Asked by At

we have a Enterprise Guide Project, where we have multiple process flows. Output of each process flow is saved to specific Library called "SAVE", defined with LIBNAME statement. This is done so that we could easier jump and work on any process flow without needing to run all above process flows (except of course the process flow which would initialize SAVE Library with LIBNAME statement).

However, when we want to run this code on PRODUCTION server, we would like that this SAVE Library points to SAS WORK Data Library, as we dont need this in-between data.

Is it possible to direct the Library to WORK Data Library, using LIBNAME Statement (e.g. "LIBNAME SAVE SAS.WORK;") ?

3

There are 3 answers

4
Tom On BEST ANSWER

The define a libref use the LIBNAME statement. To find the path used by an existing libref use the PATHNAME() function.

libname save %sysfunc(quote(%sysfunc(pathname(work)))) ;

Be careful using this trick because SAVE.memname and WORK.memname will now refer to the same physical file. Code that worked in your development environment might not work because of name conflicts.

0
Sale On

Ok, I found a way to do it.

%let workLocation=%sysfunc(getoption(work));
libname SAVE "&workLocation.";

There is even simpler solution:

libname SAVE (work);
1
Martí Mayo On

One thing you can do is reassign the WORK library so it points where your SAVE library is.

Here, in point 1, they explain how to do it: https://riskopedia.wordpress.com/2007/03/06/reassign-location-on-sas-work-folder/