BookmarkSubscribeRSS Feed
slthiya4
Calcite | Level 5

How can i make temporoary library WORK to permanant?

4 REPLIES 4
alexal
SAS Employee

@slthiya4,

 

The Work library is the temporary library that is automatically defined by SAS at the beginning of each SAS session or job. The Work library stores temporary SAS files that you create, as well as files created internally by SAS.

 

The WORKINIT and WORKTERM system options control the creation and deletion of the Work library. For more information, see WORKINIT System Option in SAS System Options: Reference and WORKTERM System Option in SAS System Options: Reference.

Ksharp
Super User
libname x v9 'c:\temp';
options user=x;
Reeza
Super User

Don't. You'll be using the system in a way that's its not really designed and its not conventional. Other programmers will be wondering what you did and then you're entirely responsible for cleaning up temporary data sets rather than allowing SAS to clean it up after each session.

 

Instead, create a permanent library and use that as needed. Unfortunately creating a permanent library is done via the GUI in most systems, or you need to assign it at the start of every program or in your autoexec. 

 

Personally, I like a permanent library for different projects in different places so I create specific permanet libraries for each project and then include that in the program for the project. 

 

 

 

 

Patrick
Opal | Level 21

@slthiya4

You can create data sets in any folder you like. It doesn't have to be WORK.

WORK is just a SAS libref created automatically by SAS and pointing to a folder location also created automatically by SAS during SAS invocation. When terminating a session SAS will automatically delete this WORK folder location. That's a good thing as it prevents you from filling up your disk with a lot of tables which you don't need.

 

The WORK folder location will be different for every single SAS session. NOWORKTERM will prevent SAS from deleting the WORK folder when terminating BUT how are you going to know the folder name in a new session?

 

SAS tables use a two level name: <libref>.<table name>. If you ommit the <libref> and just write <table name> then SAS automatically uses the libref WORK for this table.

 

 

If there are tables which you want to keep then store them in a different directory for permanent tables. Simply use a two level name <libref>.<table name> with a libref other than WORK.

Eventually create define own libname for this or use a libref which already exists and has been created for such permanent storage.

 

Another automatically created libref which will always point to your personal folder for permanent tables is SASUSER.

 

data sasuser.test;
  var='just a test';
run;
proc print data= sasuser.test;
run;

To copy all tables from your current WORK folder to SASUSER:

proc datasets lib=sasuser nolist nowarn;
  copy in=sasuser out=permwork;
  run;
quit;

And if you want to know where librefs point to (printed to SAS log):

%put WORK:    %sysfunc(pathname(work));
%put SASUSER: %sysfunc(pathname(sasuser));

The path for SASUSER will always be the same, the path for WORK will be different between SAS sessions.

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 999 views
  • 3 likes
  • 5 in conversation