Write and run SAS programs in your web browser

SASUSER library and SASDATA library

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 148
Accepted Solution

SASUSER library and SASDATA library

Hi all,

 

     I have a question about the SASUSER and SASDATA library, I read this link http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002120511.htm

But I am still not sure how these two libraries used?

For me, I usually create a random library according to the syntax:  Libname OR '/home/Jade/OR';

I really do not know the advantage of SASUSER and SASDATA library and how they used.

 

Thanks,

Jade

 


Accepted Solutions
Solution
‎03-14-2017 01:06 PM
Super User
Posts: 11,134

Re: SASUSER library and SASDATA library

SASUSER is mostly used by the SAS install. It is a bad idea to use it for data as that is one of the libraries that gets replaced by SAS during upgrades and installs.

 

USER is for those that have a need or want to reference data sets that persist from session to session with a single level name. The advantage is that not everything in the user the library is removed at the end of a session as in the WORK library. One disadvantage is that library can get very big if you have lots of temporary files that should have been written to WORK, which still exists and still is cleaned up at the end of the session. Another more subtle disadvantage is running other peoples code (such as from this forum), especially those with inconsistent use of the WORK library. If they reference something like:

data temp;

   set sashelp.class;

run;

proc print data=work.temp;

run;

Then if you have a user library the results may not match or even run because the first set gets written into USER but the print is looking in WORK. If you happen to have a different work.temp data set then the results may be quite confusing. Another potential problem is the default Format catalog can get large and temporary formats become permanent.

 

I am one of the odd ducks that do use a USER library because I work on multiple projects for multiple clients and never know when I will be interupted with a higher priority task. So I can switch tasks and my intermediate datasets don't disappear if I don't get back to the project for a few days.

I am very careful about running code from here with formats to assgn them to my work library so they do not overwrite any of my permanent formats in the User library. [I do keep the code for my formats to rebuild as needed though].

View solution in original post


All Replies
Super User
Posts: 7,444

Re: SASUSER library and SASDATA library

SASDATA is not a standard SAS library, the standard SAS libraries (as speicified in the document you linked to) are WORK, USER, SASHELP and SASUSER.

WORK exists only for the duration of a SAS process; it is created when a SAS process starts, and deleted when the process terminates normally.

USER can be used as a permanent replacement for WORK; you have to create the directory and execute the libname for it.

SASUSER is used by SAS to store customizations of the SAS session; it is automatically created when a user first uses SAS. Depending on the configuration of SAS, SASUSER can me made writable for the user.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 148

Re: SASUSER library and SASDATA library

Thanks! Normally how you use the User library?

Super User
Posts: 7,444

Re: SASUSER library and SASDATA library

To clarify: on UNIX systems, SASUSER is automatically created in the user's home directory when SAS is first used. The physical name of the directory is sasuser.v9X (X being the minor release number, so with SAS 9.4 it is sasuser.v94).

 

In a UNIX environment, I'd let SASUSER stay write-protected. Instead create a directory $HOME/mydata, and add

libname mydata '$HOME/mydata';

to the autoexec_usermods.sas file in the WorkspaceServer directory in your configuration tree. So every user has her/his private library.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 11,134

Re: SASUSER library and SASDATA library


Jade_SAS wrote:

    

For me, I usually create a random library according to the syntax:  Libname OR '/home/Jade/OR';

 


If by "random" you mean "a library to store data sets related to a specific project" then this is generally a recommended practice. If you put all of your data in one library it is not very long before you 1) have difficulty finding specific data sets 2) accidentally re-use data set names and overwrite other data you may have wanted to keep.

 

 

Frequent Contributor
Posts: 148

Re: SASUSER library and SASDATA library

Yes, I usually specify the library according to projects (I save different projects for different folder).

I never user SASuser and user library before and want to know the advantage to use it and how people use it.

Solution
‎03-14-2017 01:06 PM
Super User
Posts: 11,134

Re: SASUSER library and SASDATA library

SASUSER is mostly used by the SAS install. It is a bad idea to use it for data as that is one of the libraries that gets replaced by SAS during upgrades and installs.

 

USER is for those that have a need or want to reference data sets that persist from session to session with a single level name. The advantage is that not everything in the user the library is removed at the end of a session as in the WORK library. One disadvantage is that library can get very big if you have lots of temporary files that should have been written to WORK, which still exists and still is cleaned up at the end of the session. Another more subtle disadvantage is running other peoples code (such as from this forum), especially those with inconsistent use of the WORK library. If they reference something like:

data temp;

   set sashelp.class;

run;

proc print data=work.temp;

run;

Then if you have a user library the results may not match or even run because the first set gets written into USER but the print is looking in WORK. If you happen to have a different work.temp data set then the results may be quite confusing. Another potential problem is the default Format catalog can get large and temporary formats become permanent.

 

I am one of the odd ducks that do use a USER library because I work on multiple projects for multiple clients and never know when I will be interupted with a higher priority task. So I can switch tasks and my intermediate datasets don't disappear if I don't get back to the project for a few days.

I am very careful about running code from here with formats to assgn them to my work library so they do not overwrite any of my permanent formats in the User library. [I do keep the code for my formats to rebuild as needed though].

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 3665 views
  • 0 likes
  • 3 in conversation