The Big Four: Decoding the Differences Between Work, User, Sashelp, and Sasuser

This code is also available in: Deutsch Español Français
Simon

Expert Advice

Simon
Expert SAS et fondateur.

The USER library is one of the best-kept secrets for SAS developers. By default, if you type a one-level name like data mydata;, SAS puts it in WORK (temporary). However, if you execute libname user 'C:\myprojects';, SAS automatically redirects all one-level names to that permanent folder. This allows you to write short, clean code without libref. prefixes, while ensuring your data survives if your session crashes.

Control where your shortcuts lead: The Work vs. User dynamic.
The document presents the four main SAS© libraries:
  • Work : A temporary library automatically created at the beginning of each SAS© session. It is used to store temporary files (created by the user or internally by SAS©) and is deleted at the end of each normal session. It allows the use of single-level file names for temporary storage.
  • User : An optional library. If a User library is assigned, all files created with a single-level name are permanently stored in this library instead of the Work library. If no User library is assigned, SAS© uses the Work library by default. Files stored in the User library are not deleted at the end of the session.
  • Sashelp : A library automatically assigned by SAS©, containing data examples used in SAS© documentation, as well as catalogs, 'item stores', and other files storing SAS© site-wide parameters.
  • Sasuser : A library automatically assigned by SAS©, containing the user's personal settings and customizations, particularly in the Sasuser.Profile catalog.