Published on :
Data Access CREATION_INTERNE

Default SAS Libraries

This code is also available in: Deutsch Español Français
Awaiting validation
SAS© libraries are collections of SAS© files (like data tables or catalogs) that can be referenced using librefs. This guide details the four default libraries provided by SAS©. The Work library is temporary and is deleted at the end of each session. The User library allows permanent storage for files referenced by a single-level name, replacing the Work library for these files if assigned. Sashelp contains example data and site-specific SAS© settings. Sasuser stores personal user settings and customizations, including the Sasuser.Profile catalog.
Data Analysis

Type : CREATION_INTERNE


The examples in this documentation reference default SAS libraries (Sashelp) or describe the management of temporary and permanent data, but do not provide SAS code examples directly in this segment. Code examples for data creation or table usage will be extracted from related sections if available.

1 Code Block
DATA STEP Data
Explanation :
This example illustrates the creation and use of a temporary table 'MyTempTable' in the Work library. By specifying only the name 'MyTempTable' without a libref, SAS stores it in Work by default. This table will be automatically deleted at the end of the SAS session.
Copied!
1/* Ce code crée une table temporaire 'MyTempTable' dans la bibliothèque Work. */
2DATA MyTempTable;
3 INPUT ID Name $;
4 DATALINES;
5 1 John
6 2 Jane
7 ;
8RUN;
9 
10PROC PRINT DATA=MyTempTable;
11RUN;
2 Code Block
LIBNAME Data
Explanation :
This code block shows how to assign a 'User' library to a specified file path, designating it as the default library for permanent storage of files created with a single-level name. 'MyPermanentTable' is thus saved permanently. It also demonstrates how to force the use of the Work library for temporary data by using a two-level name (Work.AnotherTempTable) even if 'User' is active.
Copied!
1/* Assigne la bibliothèque User à un dossier pour le stockage permanent. */
2LIBNAME User '/sas/data/user_lib'; /* Remplacez par votre chemin réel */
3 
4/* Crée une table permanente 'MyPermanentTable' dans la bibliothèque User. */
5DATA MyPermanentTable;
6 INPUT Product $ Quantity;
7 DATALINES;
8 Apple 100
9 Orange 150
10 Banana 200
11 ;
12RUN;
13 
14PROC PRINT DATA=MyPermanentTable;
15RUN;
16 
17/* Si la bibliothèque User est assignée, SAS cherchera 'MyPermanentTable' ici. */
18/* Pour créer une table temporaire explicitement dans Work, utilisez un nom à deux niveaux. */
19DATA Work.AnotherTempTable;
20 INPUT Item $ Price;
21 DATALINES;
22 Pen 1.50
23 Paper 3.00
24 ;
25RUN;
26 
27PROC PRINT DATA=Work.AnotherTempTable;
28RUN;
3 Code Block
PROC CONTENTS / PROC PRINT
Explanation :
This example uses 'PROC CONTENTS' to display the tables and catalogs available in the Sashelp library. 'PROC PRINT' is then used to view a data sample from the 'Class' table in the Sashelp library, demonstrating access to data provided by SAS for documentation and examples.
Copied!
1/* Liste le contenu de la bibliothèque Sashelp. */
2PROC CONTENTS DATA=Sashelp._ALL_ NODS;
3RUN;
4 
5/* Affiche les 5 premières lignes de la table 'CLASS' de Sashelp. */
6PROC PRINT DATA=Sashelp.Class(OBS=5);
7RUN;
4 Code Block
PROC CATALOG
Explanation :
This example uses 'PROC CATALOG' to examine the contents of the Sasuser.Profile catalog. This catalog stores user settings and customizations, such as environment preferences or function key definitions. It shows the items stored in the Sasuser library for the current user.
Copied!
1/* Liste le contenu du catalogue Sasuser.Profile. */
2PROC CATALOG CATALOG=Sasuser.Profile ENTRYTYPE=ALL;
3 CONTENTS;
4RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright © SAS Institute Inc. All Rights Reserved


Related Documentation : Data Access

Sujet / Mot-cléLien vers la ressource
DOC FedSQL en/sampleCode/FEDSQL9D66
Banner
Expert Advice
Expert
Michael
Responsable de l'infrastructure Viya.
« Understanding default libraries is fundamental to managing your session’s data lifecycle. SAS uses a two-level naming convention (libref.filename). If you omit the first level (e.g., DATA MyTable;), SAS defaults to a specific storage location based on your environment configuration. Mastery of these defaults ensures you don't accidentally lose data or clutter shared resources. »